class MyClass {
constructor() { ... }
method1() {...}
method2() {...}
method3() {...}
}
class User {
constructor(name) {
this.name = name;
}
sayHi() {
alert(this.name);
}
}
let user = new User("John");
user.sayHi();
function User(name) {
this.name = name
}
User.prototype.sayHi = function(){
alert(this.name);
}
let user = new User("John");
user.sayHi();
자바스크립트에서 클래스는 함수의 한 종류이다.
https://medium.com/@bluesh55/javascript-prototype-%EC%9D%B4%ED%95%B4%ED%95%98%EA%B8%B0-f8e67c286b67