如下代码,什么情况下typeof Constructor.prototype ===

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' );


开满天机
浏览 626回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript