Skip to content

Instantly share code, notes, and snippets.

@piecioshka
Last active December 22, 2015 21:59
Show Gist options
  • Save piecioshka/6536988 to your computer and use it in GitHub Desktop.
Save piecioshka/6536988 to your computer and use it in GitHub Desktop.
undefined is the same as undefined?
// 1) simple check
console.log(undefined === undefined); // true
// 2) check undefined param in function
(function (undef) {
console.log(undef === undefined); // true
}());
// 3) unexists property
(function (obj) {
console.log(obj.x === undefined); // true
}({}));
// 4) not set value for variable
(function () {
var x;
console.log(x === undefined); // true
}());
// 5) not exists item in array
(function (arr) {
console.log(arr[1] === undefined); // true
})([5]);
// 6) define variable with 'undefined' with only create var
(function () {
var a = undefined;
var b;
console.log(a === b); // true
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment