프로토타입 = 원형객체
Human ==(.prototype)==> Human.prototype.sleep ==(new Human(); instantiation)==> steve.sleep
steve.sleep ==(.proto)==> Human.prototype.sleep ==(.constructor)==> Human
Array ==(.prototype)==> Array.prototype.push/.slice/.map/.each... ==(new Array(); instantiation)==> arr..push/.slice/.map/.each...
arr..push/.slice/.map/.each ==(.proto)==> Array.prototype.push/.slice/.map/.each.. ==(.constructor)==> Array
<생활코딩 유튜브 이미지 캡쳐: https://www.youtube.com/watch?v=wT1Bl5uV27Y>
<딥다이브 자바스크립트 p270페이지 참조>
구분 | 소유 | 값 | 사용주체 | 사용목적 |
---|---|---|---|---|
.proto | 모든 객체 | 프로토타입의 참조 | 모든 객체 | 객체가 자신의 프로토타입에 접근 또는 교체하기 위해 사용 |
prototype | constructor | 프로토타입의 참조 | 생성자 함수 | 생성자 함수가 자신이 생성할 객체(인스턴스)의 프로토타입을 할당하기 위해 사용 |