var example = function () {
console.log(typeof this);
return this;
};
在严格模式下:example.call('test') # prints 'string'
除此以外,example.call('test') # prints 'object'
但是,console.log(example.call('test'))
打印test
(如您所料)
为什么Function.call
changetypeof 'test' === 'string'
绑定到this
inside example
?