Why “foo”.toString() is not the same as toString.call(“foo”)?

后端 未结 3 2080
长发绾君心
长发绾君心 2020-12-05 12:22

Here is a question in JavaScript below:

// Tested via Google Chrome console.
var toString = Object.prototype.toString;

"foo".toString(); // "f         


        
3条回答
  •  有刺的猬
    2020-12-05 12:28

    >>> String.prototype.toString.call("foo")
    "foo"
    

    Object is not the same thing as a String.

提交回复
热议问题