//2. 工厂方式(Object关键字)
let d = new Object();
d.name = 'zhangsan'
console.log(d.name)
//3. 构造函数方法
let B = function (name) {
this.name = name
}
let c = new B('zhangsan')
console.log(c.name)
// 4. 使用原型
let E = function () { }
E.prototype.name = 'zhangsan3'
E.prototype.eat = function () {
alert('吃了苹果橘子')
}
let e2 = new E()
console.log(e2.name)
e2.eat()
// 5 混合模式(原型+构造函数)
let F = function (name) {
this.name = name
}
F.prototype.sell = function () {
alert('我买了' + this.name + '汽车')
}
let f = new F('比亚迪海陆u8')
console.log(f.name)