r/javascript • • May 28 '19

What are some JavaScript things beginners don't know?

333 Upvotes

383 comments sorted by

View all comments

Show parent comments

16

u/[deleted] May 28 '19

let me end all your struggles:

the only time you use == instead of === in JS is when you do yourVar == null because this checks for null and undefined.

2

u/[deleted] May 28 '19

Your data structures shouldn't usually be capable of being T | null | undefined, so I'd argue there's really no place for double equals in a modern codebase.

5

u/[deleted] May 28 '19

Kyle Simpson would disagree. Coercion can be useful and is a valuable part of JavaScript to understand.

-2

u/[deleted] May 28 '19

One person's opinions on the JavaScript language don't do much to rebut my opinion regarding one's data structures and how they serialise into JavaScript or indeed any other language silly enough to have null or undefined types, let alone two of them.