Does list is empty check for NULL?

null

The value nullrepresents the intentional absence of any object value. It is one of JavaScript's primitive values and is treated as falsyfor boolean operations.

Syntax

null

Description

The valuenull is written with aliteral:null. null is not an identifier fora property of the global object, like undefined can be. Instead, nullexpresses alack 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.

// foo does not exist. It is not defined and has never been initialized: foo; //ReferenceError: foo is not defined
// foo is known to exist now but it has no type or value: var foo = null; foo; //null

Examples

Difference between null and undefined

When checking for null or undefined, beware of the differences between equality [==] and identity [===] operators, as the former performs type-conversion.

typeof null // "object" [not "null" for legacy reasons] typeof undefined // "undefined" null === undefined // false null == undefined // true null === null // true null == null // true !null // true isNaN[1 + null] // false isNaN[1 + undefined] // true

Specifications

Specification
ECMAScript Language Specification [ECMAScript]
# sec-null-value

Browser compatibility

BCD tables only load in the browser

See also

  • undefined
  • NaN
  • void operator

Video liên quan

Chủ Đề