原型链笔记:
function Grand(){} Grand.prototype.age="110"; var grand=new Grand(); function Father(){ this.name="111"; } Father.prototype=grand; var father=new Father(); function Son(){ this.color="red"; } Son.prototype=father; var son=new Son();
通过设置prototype形成原型链,得到 son.name="111" 其余类似
踩坑:设置prototype一定要设置在调用构造函数之前,生成对象再设置原型是无法调用前面的属性的
增删改都只能自己弄,子孙不能
原文:https://www.cnblogs.com/tomatofjy/p/11761857.html