const hyerin = {
name: 'hyerin',
normal: function () {
console.log(this.name)
}
}
: function 생략
const hyerin = {
name: 'hyerin',
normal() {
console.log(this.name)
}
function User(first, last) {
this.firstName = first
this.lastName = last
}
User.prototype.getFullName = function () {
return ${this.firstName} ${this.lastName}
}
클래스 문법 사용
class User {
constructor(first, last) {
this.firstName = first
this.lastName = last
}
getFullName() {
return ${this.firstName} ${this.lastName}
}
}