The null
value represents the intentional absence of any object value. It is one of JavaScript's primitive values and is treated as falsy for boolean operations.
The null
value represents the intentional absence of any object value. It is one of JavaScript's primitive values and is treated as falsy for boolean operations.
The value null
is written with a literal: null
. null
is not an identifier for a property of the global object, like undefined
can be. Instead, null
expresses a lack of identification, indicating that a variable points to no object. In APIs, null
is often retrieved in a place where an object can be expected but no object is relevant.
null
and undefined
When checking for null
or undefined
, beware of the differences between equality (==) and identity (===) operators, as the former performs type-conversion.
Specification |
---|
ECMAScript Language Specification # sec-null-value |
Desktop | Mobile | Server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | Deno | Node.js | ||
null |
1 | 12 | 1 | 3 | 1 | 18 | 4 | 10.1 | 1 | 1.0 | 4.4 | 1.0 | 0.10.0 |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/null