摘要: 基于原型的继承:通过隐式原型链来实现继承 // 定义父类Animal function Animal(sex) { this.sex = sex; } Animal.prototype.gender = function () { console.log(`这只动物是${this.sex}的`); 阅读全文
posted @ 2020-12-21 21:33 时光傀儡师 阅读(124) 评论(0) 推荐(0) 编辑
摘要: let animal1 = { type: "鼠", eat(food) { console.log(`${this.type}吃${food}`); }, }; let animal2 = { type: "猫", }; animal1.eat("玉米"); //鼠吃玉米 animal1.eat. 阅读全文
posted @ 2020-12-21 21:26 时光傀儡师 阅读(95) 评论(0) 推荐(0) 编辑