1
这些函数有什么区别?有什么优点和缺点?JavaScript原型函数
let Test = function(name) {
this.name = name;
this.complete = function() {
console.log(`completing task${this.name}`)
}
}
和
let Test = function(name) {
this.name = name;
}
Test.prototype.complete = function() {
console.log(`completing task${this.name}`)
}