offline version v3


28 of 264 menu

null value

The null value means "nothing", i.e. the absence of an object or element. When performing logical operations, it is equivalent to a false statement or false. JavaScript has a similar undefined value that denotes the absence of a value. The difference is that null denotes an intentional absence (explicitly written in a code), while undefined is simply the absence of any information about the element type and its value.

Syntax

null;

Example

Let's define the variable value:

let res = null; console.log(res);

The code execution result:

null

Example

The null value is returned by methods for searching DOM elements if the element was not found:

let res = document.querySelector('#elem'); console.log(res);

The code execution result:

null

See also

  • the true value
    that indicates that the element value is true
  • the false value
    that indicates that the element value is false
  • the undefined value
    that denotes that the element value is "undefined"
enru