자바스크립트 프로토타입 프로퍼티
[자바스크립트] 함수의 prototype 프로퍼티
[자바스크립트] 함수의 prototype 프로퍼티
2021.07.16함수의 prototype 프로퍼티 let animal = { eats: true }; function Rabbit(name) { this.name = name; } Rabbit.prototype = animal; let rabbit = new Rabbit("White Rabbit"); // rabbit.__proto__ == animal alert( rabbit.eats ); // true Rabbit.prototype = animal은 "new Rabbit을 호출해 만든 새로운 객체의 [[Prototype]]을 animal로 설정하라."라는 것을 의미한다. 가로 화살표는 일반 프로퍼티인 "prototype"을, 세로 화살표는 [[Prototype]]을 나타낸다. 세로 화살표는 rabbit이 animal..