构造函数本身也是函数只不过通过new声明的话有类的特点,内部会创建一个对象实例并返回
// 3. 构造函数模式
function Animal() {
this.name = 'Dog';
this.age = 1;
this.bark = function () {
console.log('wangwang');
}
}
var dog = new Animal();
dog.bark();
dog.height = 1.0;
Animal.prototype.height = 20;
var dog2 = new Animal();
console.log(dog2.height);