function Person(){
this.name=1234;
// return {};
}
Person.prototype.getname=function(){
console.log(this.name);
}
function CreateObj(){
var fn=[].shift.call(arguments);
var args=arguments;
var obj=new Object();
var ret=fn.apply(obj,args);
obj.__proto__=fn.prototype;
return typeof ret ==='object'?ret:obj;
}
var a=CreateObj(Person);
console.log(a);
网友评论