Skip to content
Search

JavaScript:StrictEquality

lastmod 2026-02-26created 2021-07-202 edits

Equal to(==) vs Strict equal(===)

Equal to (==):

  • When both operands are the same type, true if the values are equal
  • When the operands are different types, true if the two operands become equal under predefined type conversion rules

Strict equal (===):

  • Checks whether the two operands are equal without type conversion.
  • True if the operands are primitive types and the values are equal
  • True if the operands are object types and refer to the same object
  • False if the objects have different addresses, even if their structure and contents are the same

Comparison table:

x

y

==

===

undefined

undefined

true

true

null

null

true

true

true

true

true

true

false

false

true

true

'foo'

'foo'

true

true

0

0

true

true

+0

-0

true

true

+0

0

true

true

-0

0

true

true

0

false

true

false

""

false

true

false

""

0

true

false

'0'

0

true

false

'17'

17

true

false

[1,2]

'1,2'

true

false

new String('foo')

'foo'

true

false

null

undefined

true

false

See also

Favorite sitge

author Zer0 sitemap