null

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨July 2015⁩.

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.

Try it

function getVowels(str) {
  const m = str.match(/[aeiou]/gi);
  if (m === null) {
    return 0;
  }
  return m.length;
}

console.log(getVowels("sky"));
// Expected output: 0

Syntax

js
null

Description

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.

js
// foo does not exist. It is not defined and has never been initialized:
foo; // ReferenceError: foo is not defined
js
// foo is known to exist now but it has no type or value:
const 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.

js
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
Number.isNaN(1 + null); // false
Number.isNaN(1 + undefined); // true

Specifications

Specification
ECMAScript® 2026 Language Specification
# sec-null-value

Browser compatibility

See also