ECMAScript3的原型

function Super(){ // 父类
                    
}
function Sub(){ // 子类
                
}
Sub.prototype = new Super();
Sub.prototype.constructor = Sub;
var sub = new Sub();
console.log('Sub.prototype.constructor===Sub',Sub.prototype.constructor===Sub); // true
console.log('sub.__proto__==Sub.prototype',sub.__proto__==Sub.prototype); // true
console.log('Sub.prototype.__proto__===Super.prototype',Sub.prototype.__proto__===Super.prototype); // true

 

posted on 2017-06-12 10:32  沙滩海风  阅读(132)  评论(0编辑  收藏  举报

导航