- Apr 2023
-
www.construct.net www.construct.net
-
typeof OffscreenCanvas !== "undefined"
The second
=
sign is completely superfluous here. Only one is necessary.
-
- Aug 2022
-
martinfowler.com martinfowler.com
-
It's often a good idea to replace common primitives, such as strings, with appropriate value objects.
-
-
jimmyhmiller.github.io jimmyhmiller.github.io
-
if (property === 'firstName')
Tags
Annotators
URL
-
-
firefox-source-docs.mozilla.org firefox-source-docs.mozilla.org
-
In JavaScript, == is preferred to ===.
-
- Jul 2022
-
blog.shimin.io blog.shimin.io
-
const div3 = n % 3 === 0; const div5 = n % 5 === 0;
-
-
www.reddit.com www.reddit.com
-
It made sense when JS was doing small simple things in HTML - it doesn’t make much sense anymore
No, it still makes sense.
Insisting that everyone use
===
everywhere, on the other hands, makes as much sense as disallowing method declarations that accept a parameter that implements an interface (in favor of formal parameters that insist on a certain class or a derivative), or injecting a bunch ofinstanceof
checks for no good reason... -
I have rarely encountered a good reason to use == in JS. Most of the time, or you are relying on it, you are probably doing something wrong.
-
Easier to just add a new operator that does things the right way and keep the original == operator as is. That way people can transition on their own time
Stupid myth.
-
- May 2022
-
news.ycombinator.com news.ycombinator.com
-
typeof v === "number"
Using triple equals to check the results of
typeof
is totally unnecessary, and a sure sign that someone, somewhere has unthinkingly adopted some dubious advice; it's a code smell/red flag.A standard equality comparison (using
==
) does exactly the right thing while also avoiding association with questions/doubts about the quality of the surrounding code.
-
- Mar 2022
-
people.csail.mit.edu people.csail.mit.edu
-
Lesson: use === and !==
No. Actual lesson: know your types.
-