Movatterモバイル変換


[0]ホーム

URL:


  1. Glossary
  2. Falsy

Falsy

Afalsy (sometimes writtenfalsey) value is a value that is considered false when encountered in aBoolean context.

JavaScript usestype conversion to coerce any value to a Boolean in contexts that require it, such asconditionals andloops.

The following table provides a complete list of JavaScript falsy values:

ValueTypeDescription
nullNullThe keywordnull — the absence of any value.
undefinedUndefinedundefined — the primitive value.
falseBooleanThe keywordfalse.
NaNNumberNaN — not a number.
0NumberTheNumber zero, also including0.0,0x0, etc.
-0NumberTheNumber negative zero, also including-0.0,-0x0, etc.
0nBigIntTheBigInt zero, also including0x0n, etc. Note that there is noBigInt negative zero — the negation of0n is0n.
""StringEmptystring value, also including'' and``.
document.allObjectThe only falsy object in JavaScript is the built-indocument.all.

The valuesnull andundefined are alsonullish.

Examples

Examples offalsy values in JavaScript (which are coerced to false in Boolean contexts, and thusbypass theif block):

js
if (false) {  // Not reachable}if (null) {  // Not reachable}if (undefined) {  // Not reachable}if (0) {  // Not reachable}if (-0) {  // Not reachable}if (0n) {  // Not reachable}if (NaN) {  // Not reachable}if ("") {  // Not reachable}

The logical AND operator, &&

If the first object is falsy, it returns that object:

js
console.log(false && "dog");// ↪ falseconsole.log(0 && "dog");// ↪ 0

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp