undefined and null

suggest change

At first glance it may appear that null and undefined are basically the same, however there are subtle but important differences.

undefined is the value of a binding that has not been assigned one.

Setting a variable to undefined does not remove the binding. JSON.stringify omits object properties whose values are undefined, and it keeps properties whose values are null.

The following evaluate to undefined:

undefined is also a property of the global window object.

// Only in browsers
console.log(window.undefined); // undefined
window.hasOwnProperty('undefined'); // true

Before ECMAScript 5 you could change the value of the window.undefined property. Since ES5 that global property is read-only. A local binding can still shadow undefined.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents