js undefined value code example
Example 1: javascript check for undefined
if (typeof myVariable === 'undefined'){
//myVariable is undefined
}
Example 2: js this returns undefined
function foo() {
console.log(this);
}
// normal function call
foo(); // `this` will refer to `window`
// as object method
var obj = {bar: foo};
obj.bar(); // `this` will refer to `obj`
// as constructor function
new foo(); // `this` will refer to an object that inherits from `foo.prototype`