πΒ ****Reference
πΒ Chapter
Constructor function (μμ±μ ν¨μ)
constructor() { ... }
constructor(argument0) { ... }
constructor(argument0, argument1) { ... }
constructor(argument0, argument1, ... , argumentN) { ... }
constructor
λ₯Ό μ¬μ©νλ©΄ λ€λ₯Έ λͺ¨λ λ©μλ νΈμΆλ³΄λ€ μμ μμ μΈ, μΈμ€ν΄μ€ κ°μ²΄λ₯Ό μ΄κΈ°νν λ μνν μ΄κΈ°ν μ½λλ₯Ό μ μν μ μλ€.class Person {
constructor(name) {
this.name = name;
}
introduce() {
console.log(`Hello, my name is ${this.name}`);
}
}
const otto = new Person("Otto");
otto.introduce();
constructor() {}
constructor(...args) {
super(...args);
}