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}`)
}