javaScript设计模式---(Constructor构造器模式学习)

构造器模式:构造函数+原型  创建对象

function Person (name, age) {
    this.name = name;
    this.age = age;    
}
Person.prototype.sayName = function () {
    console.log(this.name)
}

 

posted @ 2017-09-17 21:30  RunningAndRunning  阅读(82)  评论(0编辑  收藏  举报