r/javascript • • May 28 '19

What are some JavaScript things beginners don't know?

333 Upvotes

383 comments sorted by

View all comments

7

u/Jackrussell17 May 28 '19

Equality in JavaScript is very convoluted, e.g. an array containing a single element of value "0" is considered == false, but an array containing a single element of value "1" is considered == true.

So it's really best to try to use === and !== where possible, only using == and != where absolutely necessary. Things are more predictable that way.

See this table for a full rundown: https://dorey.github.io/JavaScript-Equality-Table/unified/