3 ms·
The result of == on strings is defined as comparison UTF-16 code unit by UTF-16 code unit (non-normalised). The result of == on what the spec calls "Object valu
by tuukkah 4y ago
The result of == on strings is defined as comparison UTF-16 code unit by UTF-16 code unit (non-normalised). The result of == on what the spec calls "Object values" (including arrays) is by identity.
Here's the spec: https://tc39.es/ecma262/#sec-samevaluenonnumber https://tc39.es/ecma262/#sec-samevaluenonnumber
> 7.2.12 SameValueNonNumber ( x, y )
[...]
> 5. If x is a String, then
> a. If x and y are exactly the same sequence of code units (same length and same code units at corresponding indices), return true; otherwise, return false.
[...]
> 8. If x and y are the same Object value, return true. Otherwise, return false.
- eyelidlessness 4y agoIs it okay if I snickered? Because I did snicker.
- tuukkah 4y agoSure, although trying to decipher the spec more typically makes me want to cry. (Where do they define the "sameness" of "Object values"?)