
prototype
·
JavaScript
prototype" data-ke-type="html">HTML 삽입미리보기할 수 없는 소스객체간의 상속을 구현하는 개념function MakeFunc(name) { this.name = name; // this는 생성될 객체를 가르킨다.}MakeFunc.prototype.greeting = function () { console.log(`hello ${this.name}`) };const newFunc = new MakeFunc("Kim");위 코드를 전제로 프로토타입을 한번 알아보자.생성자 함수 MakeFunc을 만든다. (화살표 함수는 this 바인딩이 없다.). 생성자 함수엔 prototype 이라는 객체가 기본적으로 내장되어 있다. 이 prototype 객체에 greeting 메서드를 추가했다..