javaScript设计模式---(Constructor构造器模式学习)
构造器模式:构造函数+原型 创建对象
function Person (name, age) { this.name = name; this.age = age; } Person.prototype.sayName = function () { console.log(this.name) }
构造器模式:构造函数+原型 创建对象
function Person (name, age) { this.name = name; this.age = age; } Person.prototype.sayName = function () { console.log(this.name) }