I want to know what the difference is between null
and undefined
in JavaScript.
Both Null and undefined in JavaScript indicate absence of value.
var a = null; //variable assigned null value var b; // undefined
Despite the fact both exist for absence of value but: Undefined actually means the variable is not initialized. Functions that return nothing and function parameters for which no value is supplied, undefined value is returned. Use strict equality operator === to distinguish between null and undefined.
Reference: http://www.thesstech.com/javascript/null-and-undefined