function A( name ){ this.name = name;} function ObjectFactory(){ //console.log(arguments); var obj = {}, Constructor = Array.prototype.shift.call( arguments ); //console.log(typeof Constructor.prototype); obj.__proto__ = typeof Constructor.prototype === 'number' ? Object.prototype : Constructor.prototype; var ret = Constructor.apply( obj, arguments ); //console.log(typeof ret); return typeof ret === 'object' ? ret : obj; } var a = ObjectFactory( A, 'svenzeng' );
添加回答
举报
0/150
提交
取消