//es5 继承
function Phone (brand,price) {
this.brand = brand
this.price = price
}
// 添加方法
Phone.prototype.call = function () {
console.log('我可以打电话')
}
function StartPhone (brand,price,color,size) {
Phone.call(this,brand,price)//这是实例化对象的this
this.color = color
this.size = size
}
// 设置子集构造函数的原型
StartPhone.prototype = new Phone;
// 声明子类的方法
StartPhone.prototype.poto = function () {
console.log('我可拍照')
}
const chuizi = new StartPhone('锤子','2645','black',"5.5inch")
console.log(chuizi)
chuizi.call()
chuizi.poto()
console.log(chuizi)
console