If I open the console and enter...
var f=function(a){
this.toString=function(){
return "-->"+a;
}
},i=new f(5);
i;
...it returns ({toString:(function () {return "-->" + a;})})
.
But if I enter...
var f=function(a){
this.toString=function(){
return "-->"+a;
}
},i=new f(5);
alert(i);
...it alerts "-->5"
It doesn't matter me very much, but I would prefer the first code to return "-->5"
. Is there a way to do that, or is it intentional that the console doesn't use toString
?