Triple equal measure the value as well as type. But I want to know the order like it first compares the value and returns on false or vice versa.
-
3Why exactly do you think it matters?VLAZ– VLAZ2021-09-10 17:32:06 +00:00Commented Sep 10, 2021 at 17:32
-
The type is checked first. Here's "The Strict Equality Comparison Algorithm" from the JavaScript (ECMAScript) spec: 262.ecma-international.org/5.1/#sec-11.9.6gen_Eric– gen_Eric2021-09-10 17:34:24 +00:00Commented Sep 10, 2021 at 17:34
-
1The accepted answer in the linked duplicate links to the official standard, if you're interested in the nitty gritty: 262.ecma-international.org/5.1/#sec-11.9.6deceze– deceze ♦2021-09-10 17:34:40 +00:00Commented Sep 10, 2021 at 17:34
Add a comment
|
1 Answer
It checks the type first:
https://262.ecma-international.org/5.1/#sec-11.9.6
If Type(x) is different from Type(y), return false.
If Type(x) is Undefined, return true.
If Type(x) is Null, return true.
If Type(x) is Number, then
If x is NaN, return false.
If y is NaN, return false.
If x is the same Number value as y, return true.
If x is +0 and y is −0, return true.
If x is −0 and y is +0, return true.
Return false.
If Type(x) is String, then return true if x and y are exactly the same sequence of characters (same length and same characters in corresponding positions); otherwise, return false.
If Type(x) is Boolean, return true if x and y are both true or both false; otherwise, return false.
Return true if x and y refer to the same object. Otherwise, return false.