Movatterモバイル変換


[0]ホーム

URL:


MDN Web Docs

null

BaselineWidely available

Thenull value represents the intentional absence of any object value. Itis one of JavaScript'sprimitive values andis treated asfalsy 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 valuenull is written with a literal:null.null is not an identifier for a property of the global object, likeundefined can be. Instead,null expresses a lack of identification, indicating that a variable pointsto no object. In APIs,null is often retrieved in a place where an objectcan 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 betweennull andundefined

When checking fornull orundefined, beware of thedifferences between equality (==) and identity (===) operators, as the former performstype-conversion.

js
typeof null; // "object" (not "null" for legacy reasons)typeof undefined; // "undefined"null === undefined; // falsenull == undefined; // truenull === null; // truenull == null; // true!null; // trueNumber.isNaN(1 + null); // falseNumber.isNaN(1 + undefined); // true

Specifications

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

Browser compatibility

See also

Help improve MDN

Learn how to contribute.

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp