标签:
/** * Created by Administrator on 2015/5/11. */ var Super = function(){ }; Super.prototype.sayHello = function(){}; var Sub = function(){ Super.call(this); }; Sub.prototype = new Super(); Sub.prototype.constructor = Sub;//为什么要指回来? //因为Sub.constructor变成了Super, // 构造函数如果需要辨别自己是谁构造出来的,就需要指回来 Sub.prototype.subSayHello = function(){}; var sub = new Sub(); var s = new Super(); sub.constructor === Sub //true sub.constructor === Super //false sub.__proto__ instanceof Super //true sub.__proto__ instanceof Sub //false
标签:
原文地址:http://www.cnblogs.com/lihaozhou/p/4495823.html