function User(first, last){
this.firstName = first
this.lastName = last
}
User.prototype.getFullName = function () {
return `${this.firstName} ${this.lastName}`
}
const heropy = new User('Heropy', 'Park');
const neo = new User('Neo' , 'Anderson')
console.log(heropy);
console.log(neo);
위의 코드를 class 방식으로 수정해보자
class User {
constructor(first , last){
this.firstName = first
this.lastName = last
}
getFullName(){
return `${this.firstName} ${this.lastName}`
}
}