Maybe this question is easy,but I can’t understand now.
String.prototype.self=function()
{
return this;
}
var s="s";
alert("s".self()=="s".self()) //false;
alert(s.self()==s.self()) //false;
If you know the reason, please tell me why the result is “false”.
That’s because when a property is accessed from a primitive value, such as
"s", the property accesors coerce it internallyToObject, and the comparison fails because it checks two different object references.For example:
It’s like comparing: