File tree Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,10 @@ function stringify(obj) {
55 if ( obj instanceof Date ) {
66 return 'new Date(' + stringify ( obj . toISOString ( ) ) + ')' ;
77 }
8+ if ( obj === undefined ) {
9+ return 'undefined' ;
10+ }
811 return JSON . stringify ( obj )
912 . replace ( / \u2028 / g, '\\u2028' )
1013 . replace ( / \u2029 / g, '\\u2029' ) ;
11- }
14+ }
Original file line number Diff line number Diff line change @@ -7,5 +7,7 @@ assert(stringify('foo') === '"foo"');
77assert ( stringify ( 'foo\u2028bar\u2029baz' ) === '"foo\\u2028bar\\u2029baz"' ) ;
88assert ( stringify ( new Date ( '2014-12-19T03:42:00.000Z' ) ) === 'new Date("2014-12-19T03:42:00.000Z")' ) ;
99assert ( stringify ( { foo : 'bar' } ) === '{"foo":"bar"}' ) ;
10+ assert ( stringify ( undefined ) === 'undefined' ) ;
11+ assert ( stringify ( null ) === 'null' ) ;
1012
1113console . log ( 'tests passed' ) ;
You can’t perform that action at this time.
0 commit comments