거꾸로 바라본 세상
[ES6] Class(클래스)
Language/Javascript 2023. 4. 20. 09:16

[ES6] Class(클래스) 클래스는 프로토타입 기반 객체 지향 패턴을 더 쉽게 사용할 수 있게 할 수 있는 대체제로 클래스 패턴 생성을 더 쉽고 간단하게 생성할 수 있다. //클래스 선언 class Person { //constructor 생성자 constructor(name) { this._name = name; } Hello() { console.log('Hello! ' + this._name); } } const me = new Person("Paik"); const friends = new Person("Lee"); me.Hello(); friends.Hello(); 인스턴스 생성 new 연산자를 이용하여 클래스 인스턴트를 생성한다. class Foo {} const foo = new Foo(..