Skip to content

Instantly share code, notes, and snippets.

@piecioshka piecioshka/undefined.js
Last active Dec 22, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.