I graduated in 1990 in Electrical Engineering and since then I have been in university, doing research in the field of DSP. To me programming is more a tool than a job.
the rules for equality when using == are quite complex
Alas, that is one of the worst sin of JavaScript. == is not even transitive, which is a basic property that you would expect from equality. It is not just an academic matter, some algorithms (e.g., sorting) make the implicit hypothesis that equality is transitive and they can break down if it is not. The reason why we do not observe many break downs is that in sorting procedures data are of the same type and this "feature" of JS == (but also PHP has the same problem) does not manifest itself.
I graduated in 1990 in Electrical Engineering and since then I have been in university, doing research in the field of DSP. To me programming is more a tool than a job.
If the operands are of different types, try to convert them to the same type before comparing:
When comparing a number to a string, try to convert the string to a numeric value.
If one of the operands is a boolean, convert the boolean operand to 1 if it is true and +0 if it is false.
If one of the operands is an object and the other is a number or a string, try to convert the object to a primitive using the object's valueOf() and toString() methods.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
wait what is
===
and==
and=
in jsthree equal to sign is very confusing
Jon has explained it very simply!
It might help you to get a basic idea of JS operator with this article
dev.to/sumusiriwardana/beginners-g...
=
is assignment==
is equality (no type checking)===
is strict equality (type checking)My explanation here is greatly simplified - the rules for equality when using
==
are quite complexAlas, that is one of the worst sin of JavaScript. == is not even transitive, which is a basic property that you would expect from equality. It is not just an academic matter, some algorithms (e.g., sorting) make the implicit hypothesis that equality is transitive and they can break down if it is not. The reason why we do not observe many break downs is that in sorting procedures data are of the same type and this "feature" of JS == (but also PHP has the same problem) does not manifest itself.
I do not have the possibility of checking it, but if I remember correctly
is true because since both sides "look" like floating point numbers, they are converted both to float before doing the comparison.
MDN: Equality (==) — Comparison with type conversion