這裏我的問題,我不知道如何做所謂的「objectchanger」的方法效果 路過這裏是源通過參考在JavaScript(調用方法)
function test()
{
this.value=5;
}
test.prototype.Add=function()
{
this.value++;
};
var obj = new test();
obj.Add();
alert(obj.value);
function objectchanger(fnc, obj)
{
fnc.call(obj);
//obj.fnc(); >> without this line of code it works fine but why?????
//why i don't need to write this code --
}
objectchanger(obj.Add, obj);
alert(obj.value); // the value is now 7