function testObject(){ this.commonFun=function() { console.log(arguments.callee.caller);
}
}
(function () { function test1() { this.test = "test1";
this.testFun = function () {
(new testObject()).commonFun();
}
} var test1 = new test1();
test1.testFun();
}());
(function () { function test2() { this.test = "test2";
this.testFun = function () {
(new testObject()).commonFun();
}
} var test2 = new test2();
test2.testFun();
}());上面的console.log() 打印的調(diào)用函數(shù),但我現(xiàn)在想要的是調(diào)用對(duì)象的信息,如,test1對(duì)象調(diào)用的返回的是test1的test屬性,就是輸出 test1,test2對(duì)象調(diào)用的返回的是test2的test屬性,就是輸出 test2函數(shù)commonFun作用是輸出調(diào)用對(duì)象的的某些屬性,就像上面的test屬性,不能傳入?yún)?shù)
javascript 函數(shù)取得調(diào)用對(duì)象的信息。
繁星淼淼
2018-09-13 14:09:20