问题
Array.prototype.toString = function(){
return "testing";
}
a1 = [1,2,3];
console.log(a1); // returns [1,2,3]
console.log(a1.toString()); // returns "testing"
why is that? How does the first log print out values? I thought it used the toString method?
回答1:
For Firefox(both Firebug and Dev Web Console), Chrome: No
For IE: Yes
来源:https://stackoverflow.com/questions/13244308/in-javascript-does-console-log-on-an-object-call-tostring