포로토타입
-
[JS] chapter17. 프로토타입과 클래스codeStates front-end/Java Script 2023. 1. 13. 11:38
📌프로토 타입과 클래스 프로토타입 기반 언어 프로토 타입은 원형 객체를 의미 객체의 특성을 다른 객체로 상속하는 것을 가능하게 하는 매커니즘;] __proto__ 특정 객체의 프로토타입 객체에 접근할 수 있는 property es6부터 getPrototypeof 호출 __proto__ 와 .prototype 의 차이 __proto__ 모든 객체가 가지고 있다. 하나의 Link 라고 할 수 있다. prototype 함수 객체만 가지고 있다. 생성자를 가지는 원형으로 선언 할 수 있다. 실습코드 class Human { constructor(name, age) { this.name = name; this.age = age; } sleep() { console.log(`${this.name}은 잠에 들었습니다..