var f = function(o){ return this+":"+o+"::"+(typeof this)+":"+(typeof o) };
f.call("2", "2");
// "2:2::object:string"
var f = function(o){ return this+":"+(typeof this)+":"+(typeof o); };
var x = [1,/foo/,"bar",function(){},true,[],{}];
for (var i=0;i<x.length;++i) console.log(f.call(x[i],x[i]));
// "1:object:number"
// "/foo/:object:object"
// "bar:object:string"
// "function() {\n}:function:function"
// "true:object:boolean"
// ":object:object"
// "[object Object]:object:object"
我在Chrome,Firefox和Safari中看到了相同的结果,所以我假设它是每the spec,但是......为什么?规范中的这个定义在哪里?为什么不为功能?为什么`typeof this`返回“object”?
哇,从来不知道。现在我想知道为什么这也是! – Matt 2010-12-08 18:03:05