反正我是猜错,关于javascript包装对象的一个坑

function fn() {
    console.log(typeof this == 'string');
}
fn.call('str');    // consoler: true还是false?false!

 

why?

function fn() {
    console.log(this);
}
fn.call('str');    // String{0: "s", 1: "t", 2: "r"}

this是一个字符串包装对象。

posted @ 2014-02-09 13:07  MyNameIsJim  阅读(108)  评论(0编辑  收藏  举报