Created
June 13, 2012 19:43
-
-
Save rwaldron/2926029 to your computer and use it in GitHub Desktop.
null is not undefined.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://traceur-compiler.googlecode.com/git/demo/repl.html | |
// open the console | |
// paste this into the text area. | |
// | |
// or | |
// | |
// Run in Firefox 15 (Nightly) | |
function nullIsNotUndefined( arg = "foo" ) { | |
return arg; | |
} | |
console.log( nullIsNotUndefined() === "foo" ); | |
console.log( nullIsNotUndefined(null) === null ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The end result is,
undefined
andnull
have been spec'ed as having very similar behavior. Their main difference is in their meaning. The standard library usesnull
very sparingly, but quite frankly each of its use could be replaced byundefined
without losing anything.