728x90 반응형 정적 메소드1 [JS] 클래스(class): 정적 메소드(static method)와 프로토타입 메소드(prototype method)의 차이 클래스(Class)는 ES6에서 도입된 기능이다. class 키워드를 사용하여 정의하며, 내부 몸체에 3가지 종류의 메소드를 사용할 수 있다. 이 세가지 종류가 바로 생성자, 프로토타입 메소드, 그리고 정적 메소드이다. class Character { // 1. 생성자 constructor(name) { this.name = name this.level = 1 this.job = "adventurer" } // 2. 프로토타입 메소드 introduce() { return `Hello, I'm ${this.name} and my level is ${this.level}.` } // 3. 정적 메소드 static complain() { return `Oh man! What is that smell?` } }.. 2021. 10. 4. 이전 1 다음 728x90 반응형