function aFun(){ function _(arg){ this.arg = arg; } _.prototype.testFun = function(){ console.log('this is prototype testFun') }; _.testFun2 = function(){ console.log('this is testFunc2'); }return _; }; var afun = new aFun('123'); console.log(afun instanceof aFun) afun.testFun2(); //可以调用 afun.testFun(); //不是在原型链上么?,为啥不可以调用???, var aFun2 = (function (){ function _(arg){ this.arg = arg; } _.prototype.testFun = function(){ console.log('this is prototype testFun') }; _.testFun2 = function(){ console.log('this is testFunc2'); } return _; })(); var afun2 = new aFun2('ddd'); console.log(afun2 instanceof aFun2) afun2.testFun2(); //不可以调用,为啥? afun2.testFun(); //可以调用,为啥可以?(我要疯了)
相关分类