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' );
如下代碼,什么情況下typeof Constructor.prototype ===
開滿天機(jī)
2018-08-07 09:09:20