constructor

차노·2023년 8월 3일
0

JS

목록 보기
12/96

The constructor methods is a special method of a class for creating and initializing an object instance of that class.

클래스 내부에서 객체 인스턴스를 만들고 초기화하는 메소드이다.

Description

A constructor enables you to provide any custom initialization that must be done before any other methods can be called on an instantiated object.

Within the constructor body, you can access the object being created through this and access the class that is called with new through new.target.

The constructor method may have a return value. While the base class may return anything from its constructor, the derived class must return an object or undefined, or TypeError will be thrown.

Reference

0개의 댓글