例1:
var a={}; alert(a); //[object Object];
例2:
var a={
toString:function(){
return 1;
}
}
alert(a); // 1
a+1; //2
例3:
var a={toString:function(){return 1;},valueOf:function(){reuturn 2};}
alert(a); // 1
a+1; // 3
---------------------------------------------------------------------------------------------------------------------------------------------------
+操作会如下步骤:
-
Let lref be the result of evaluating AdditiveExpression.
-
Let lval be GetValue(lref).
-
Let rref be the result of evaluating MultiplicativeExpression.
-
Let rval be GetValue(rref).
-
Let lprim be ToPrimitive(lval).
-
Let rprim be ToPrimitive(rval).
-
Return the result of applying the addition operation to ToNumber(lprim) andToNumber(rprim). See the Note below 11.6.3.
+ specification: http://es5.github.io/index.html#x11.6.1