Last active
December 22, 2015 21:59
-
-
Save piecioshka/6536988 to your computer and use it in GitHub Desktop.
undefined is the same as 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
// 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