Class
ννμ
class User {
constructor(name) {
//μμ±μ
this.name = name;
}
sayHi() {
alert(this.name);
}
}
let user = new User('John');
user.sayHi();
alert(typeof User); // function
alert(User === User.prototype.constructor); // true
alert(User.prototype.sayHi); // alert(this.name);
alert(Object.getOwnPropertyNames(User.prototype)); // constructor, sayHiμ리
μΌλ°μ μΈ μμ±μ ν¨μμ λ€λ₯Έμ
getter/setter
ν΄λμ€ νλ
Last updated