Skip to content

Instantly share code, notes, and snippets.

@eliperelman
Created July 6, 2011 02:50
Show Gist options
  • Save eliperelman/1066444 to your computer and use it in GitHub Desktop.
Save eliperelman/1066444 to your computer and use it in GitHub Desktop.
Comparing against undefined
var value;
// Antipattern:
if (value === undefined) {
// code here
}
// Good pattern:
(function (undefined) {
if (value === undefined) {
// code here
}
})();
// Better pattern:
if (typeof value === 'undefined') {
// code here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment