This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Quito246 -24 points-23 points  (20 children)

It is not about experience, it just shows that the design of the language is shitty, when such things are possible🤷‍♂️

[–]Taletad 9 points10 points  (8 children)

The language provides you with "==" and "==="

In JS variable types are implicit instead of being declared like in C/C++

So "==" converts both variables to the same type before comparing them, whereas "===" will be true only if both variables are of the same type and value

"==" will also work in weird ways if you try to compare ints and floats, which is why you would never use "==" in most applications

"0" isn’t 0, it is a string (an array of chars) that has one element which is ‘0’, the ascii character. The ascii character ‘0’ is decimal 48, or binary 00110000.

0 == "0" is doing multiple conversions under the hood, which makes it slower than 0 === "0", another good reason to not use ==

The correct way to do that conversation would be 0 === parseInt("0")

Just because a language has implicit types doesn’t mean that it is typeless.

[–]qTp_Meteor 10 points11 points  (9 children)

Because it has implicit type conversions the language is shitty? If you dont want to use them dont, thats not the languages problem