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