7513179
2021-10-25 15:56
Course.prototype.study = function() { console.log(`我要学习${this.name}, 价格是${this.price}`) }
这里的name和price不是变量,是对象的属性,这里的this指的是当前对象。
比如:
const a = new Course('xxx', 10) // 这时候this指向a
const b = new Course('yyy', 20) // 这时候this指向b
带你快速入坑ES6
11727 学习 · 42 问题
相似问题