把一個函數賦值給一個變量,這個變量就是函數了,訪問變量要加()了?
var?o={?prop:40} function?indenpend(){ ?return?this.prop; } o.f=independent;//意思是說f:function?independent(){}; console.log(o.f());//為哈不會說console.log(o.f);
var?o={?prop:40} function?indenpend(){ ?return?this.prop; } o.f=independent;//意思是說f:function?independent(){}; console.log(o.f());//為哈不會說console.log(o.f);
2016-03-13
舉報
2016-03-13
o.f指向的是函數對象, o.f()返回函數執(zhí)行的結果
2016-10-19
o.f=independent相當于給對象添加了一個方法。o.f()拿到的是對象的方法,哦,o.f拿到的是一個函數。