您的位置:首页 > Web前端 > JavaScript

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

2017-06-19 21:53 239 查看

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

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);
}
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐