Reliable JavaScript Certification Online #

The undefined type is a data type of a special value undefined which is the only one value of this type. The undefined is predefined global variable and is initialized to the undefined value. It indicates that value is not defined.
This value is returned:
By a variable that is declared but not initialized,
Referring to an object property that does not exist,
Referring to an array element that does not exist.

var x;
var y = [10, 20];
var z = {alpha: 33};
//var v;

console.log(x); // undefined

console.log(y[1]); // 20
console.log(y[3]); // undefined

console.log(z.alpha); // 33
console.log(z.beta); // undefined

console.log(v); // ReferenceError

Note that by referring to a variable that has not been declared, the undefined value will not be returned but an ReferenceError is thrown.