Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

javascript

What are falsy values in Javascript?

Sarvech Qadir

JavaScript offers a special list of seven values known as falsy values. These values have the unique trait of always evaluating false in a condition statement.

The following list explains how to identify falsy values:

  1. the number 0
  2. the BigInt 0n
  3. the keyword null
  4. the keyword undefined
  5. the boolean false
  6. the number NaN
  7. the empty string "" (equivalent to '' or ``)

There are a few properties of falsy values to keep in mind:

  1. 0==0n==false=="": The values 0, 0n, false, and "" are closely equal to each other. This means that if you write 0==false in a condition, the condition will return true.

  2. null==undefined: The null and undefined values are closely equal to each other. This means that if you write null==undefined in a condition, the condition will return true.

  3. NaN does not equal anything, not even itself.

RELATED TAGS

javascript

CONTRIBUTOR

Sarvech Qadir
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring