function Health(name) {
this.name = name;
}
Health.prototype.showHealth = function () {
console.log(`${this.name}님 안녕하세요.`);
}
const h = new Health("nsunny");
h.showHealth();
class Health {
constructor (name, lastTime) {
this.name = name;
this.lastTime = lastTime;
}
showHealth() {
console.log(`안녕하세요 ${this.name}`);
}
}
const myHealth = new Health("nsunny");
myHealth.showHealth();
class
가 아니라function
이다.
console.log(typeof Health); // function