프로토타입(Prototype)
객체 표현법
객체 리터럴 (Singletone)
const healthObj = {
name : "홍길동",
lastTime : "PM 10:12",
showHealth() {
console.log(this.name + "님, 오늘은 " + this.lastTime + "에 운동을 하셨네요");
}
}
healthObj.showHealth();Class (ES2015)
const Health = class {
constructor(name, healthTime) {
this.name = name;
this.healthTime = healthTime;
}
showHealth(){
console.log(this.name + "님, 오늘은 " + this.healthTime + "에 운동을 하셨네요");
}
}
const ho = new Health("홍길동", "PM 10:12");
ho.showHealth();Constructor Pattern
Prototype Pattern
Object.create()
Last updated