There is in the ECMAScript Language Specification 11.9.1 The Equals Operator (==):
NOTE 3 The equality operator is not always transitive. For example, there might be two distinct String objects, each representing the same String value; each String object would be considered equal to the String value by the == operator, but the two String objects would not be equal to each other. For Example:
new String("a") == "a"and"a" == new String("a")are both true.new String("a") == new String("a")is false.
but in 11.9.6 The Strict Equality Comparison Algorithm:
7. Return true if
xandyrefer to the same object. Otherwise, return false.
But no, with jsc
new String("a")===new String("a")
is true.
Is that a jsc.exe error? Or are they the same object? Than why?
The operator === in js return true if is equal type and equal value. So is correct that it return true because they are both String object and their value is "a".
Have a look at the documentation http://www.w3schools.com/js/js_comparisons.asp
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With