我使用anotherFunction
函数基于来自对象someObject
的someFunction
定义了一个名为anotherObject
的对象。基于另一个对象的属性定义对象的属性
var someObject={
someFunction:function(){
return this;
}
};
console.log(someObject.someFunction()===someObject);//true
var someFunc=someObject.someFunction;
console.log(someFunc===someObject.someFunction);//true
//the function does not have the same context as that of the function called earlier...
console.log(someFunc()===someObject);//false
var anotherObject={
anotherFunction:someObject.someFunction
};
console.log(anotherObject.anotherFunction===someObject.someFunction);//true
console.log(anotherObject[anotherFunction]()===anotherObject);//true;
console.log(anotherObject.anotherFunction()===someObject);//false
Firefox Scratchpad报告未定义功能anotherFunction
。
(函数(){})==(函数(){}) – bjb568
'anotherObject [anotherFunction] ()'是垃圾 – Bergi
你的问题到底是什么? – Bergi