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() 打印的調用函數(shù),但我現(xiàn)在想要的是調用對象的信息,如,test1對象調用的返回的是test1的test屬性,就是輸出 test1,
test2對象調用的返回的是test2的test屬性,就是輸出 test2
函數(shù)commonFun作用是輸出調用對象的的某些屬性,就像上面的test屬性,不能傳入?yún)?shù)