Identity. “A is literally B” instead of “A equals B”. This is necessary here in JS because if A is the string “-1” and B is the integer -1, JS evaluates A==B as true because reasons
because if A is the string “-1” and B is the integer -1, JS evaluates A==B as true because reasons
Interesting. If it were the other way around, I think I would have been fine with it (i.e. == used for comparison with type like any other language and === without type). But as it stands now I would hate it if I had to write in JS (but I don’t so it’s fine).
Honestly, I think it actually makes some sense this way around. To me, in JS “==” is kinda “is like” while “===” is “is exactly”. Or, put another way, “equals” versus idk, “more-equals”. I mean, “===” is a much stronger check of equivalence than normal “==”, so I think it deserves to be the one with the extra “=”
2 equal signs will coerce the second operand into the type of first operand then do a comparison of it can. so 1 == “1” is true. this leads to strange bugs.
3 equal signs do not do implicit type conversion, cuts down on weird bugs. 1===“1” is false.
what does 3 equals signs do
Identity. “A is literally B” instead of “A equals B”. This is necessary here in JS because if A is the string “-1” and B is the integer -1, JS evaluates A==B as true because reasons
Interesting. If it were the other way around, I think I would have been fine with it (i.e.
==
used for comparison with type like any other language and===
without type). But as it stands now I would hate it if I had to write in JS (but I don’t so it’s fine).Honestly, I think it actually makes some sense this way around. To me, in JS “==” is kinda “is like” while “===” is “is exactly”. Or, put another way, “equals” versus idk, “more-equals”. I mean, “===” is a much stronger check of equivalence than normal “==”, so I think it deserves to be the one with the extra “=”
2 equal signs will coerce the second operand into the type of first operand then do a comparison of it can. so 1 == “1” is true. this leads to strange bugs.
3 equal signs do not do implicit type conversion, cuts down on weird bugs. 1===“1” is false.
edit: it appears to be more complicated than that for double equals and the position of operands don’t matter. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Equality
wow that seems super useful, thanks