| Null | Undefined |
|---|---|
| A null is an object with no value. | Undefined is a type. |
| Null is an intentional absence of the value. It is one of the primitive values of JavaScript. | In Undefined, the value does not exist in the compiler. It is the global object. |
typeof null; // "object" |
typeof undefined; // "undefined" |
| Null is equal to undefined but not identical. null == undefined // true |
null === undefined // false |
| A variable is defined as null when trying to convey that the variable is empty. | A variable is defined as undefined when we try to convey that the variable does not exist or is not available. |
| Null is also referred to as false. Example : null ? console.log("true") : console.log("false") // false |
When a variable is not assigned a value, it is called Undefined. Example : var temp;if(temp === undefined)console.log("true");elseconsole.log("false"); |