r/javascript • • Mar 02 '19

Useful javascript one-liners.

https://medium.com/@smellycode/js-one-liners-8bc0a6af2345?source=friends_link&sk=a9295a05aef9e514e137fca7eeb89cd1
344 Upvotes

96 comments sorted by

View all comments

43

u/Shaper_pmp Mar 02 '19

Why on earth would anyone use a font for programming that runs characters together and makes it difficult or impossible to determine whether something is a double- or triple-equals?

With a language like JS that's just asking for trouble...

5

u/taniket Mar 02 '19

If you are using double = rather then triple, there's something wrong with your code other than the font.

-1

u/benihana react, node Mar 02 '19

that's great in theory and all. but in practice, on the web, a lot of values get coerced to strings, so it's not really that straightforward.

sometimes you have to deal with the fact that something that is represented as 35 in your database will be represented as "35" in your UI. Using strict equality will lead to subtle bugs in these kinds of situations.

8

u/folkrav Mar 02 '19

There's something wrong with your architecture if you're straight up comparing DB and UI values. For the odd time these things happen, I still much prefer to go with strict equally and cast manually. It's much easier to reason with, and easily testable.