
[[Prototype]]은 숨김 프로퍼티 이자 내부 프로퍼티 이다.
__proto__
아니 마크다운 적용돼서 ㅅㅂ
암튼 저거를 property에 넣거나 method로 사용해서 prototype으로 만들 객체를 정해주면 된다
let animal = { eats: true }; let rabbit = { jumps: true }; rabbit.__proto__ = animal;
Property에 넣어서 적용한 방식
let animal = { eats: true }; let rabbit = { jumps: true __proto__: animal };
아 개그튼 색상 코드블락 이게 더 잘보이네
객체에서 없는 Property가 있다면, Prototype에서도 한번 검사를 해준다.
rabbit의 경우, eats라는 property가 없지만 prototype으로 지정된 animal에 eats가 있기 때문에 요걸 이용함!
prototype의 특징
예시 문제

let hamster = {
stomach: [],
eat(food) {
//this.stomach.push(food);
this.stomach = [food];
}
};
let speedy = {
__proto__: hamster
};
let lazy = {
__proto__: hamster
};
speedy.eat("apple");
alert(speedy.stomach);
alert(lazy.stomach);
이런식으로 고쳐주면 아예 호출한 . 앞의 객체에 새로운 property를 만들어주는거다!!
그럼 각자의 stomach가 생기게 되고, 음식도 각각 들어가게 되니까 문제 해결 왈료!!!
