CodesJava

Easy learning with example program codes

Difference between undefined value and null value


Undefined variable: A variable which is declared but value is not defined for that.
Undefined value: A value that is not defined and has no keyword is known as undefined value.
Example:

var testNum;
console.log(testNum);
// undefined

Note: Undefined is of the type undefined.

var testNum;
console.log(typeof testNum);
// undefined

Null value: A value that is explicitly specified by the keyword “null” is known as null value.

var test= null;
console.log(test);
// null

Note: null is of the type Object.

var test= null;
console.log(typeof test);
// object

Related topics:

Please follow and like us:


Copyright © 2019 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki