생성자함수1 [JS] 클래스 - 생성자 함수 (prototype) 다음과 같이 여러 번 비슷한 코드가 반복되는 경우 생성자 함수를 사용할 수 있다. 생성자 함수란 new키워드를 사용하는 함수이다. const flyda = { firstName: 'Flyda', lastName: 'Yang', getFullName : function () { return `${this.firstName} ${this.lastName}` } } console.log(flyda.getFullName()) const amy = { firstName: 'Amy', lastName: 'Hwang', getFullName : function () { return `${this.firstName} ${this.lastName}` } } console.log(amy.getFullName()) cons.. 2022. 4. 15. 이전 1 다음