javascript--面向对象(五)动态原型模式

来源:互联网 发布:android vr java 编辑:程序博客网 时间:2024/04/29 10:01

动态原型模式(让你的代码都 封装在一起  封装性)

function Person(name,age,friends,job){this.name = name;this.age =age;this.friends = friends;this.job;        //动态原型方法if(typeof this.sayName != "function"){Person.prototype.sayName = function(){console.info(this.name);}}}