[javascript] 프로토타입과 클래스

tnsdlznf23·2023년 3월 15일
0

프로토타입

  • 자바스크립트의 객체는 Prototype이라는 숨김 프로퍼티를 갖는다. 이 숨김 프로퍼티 값은 null이거나 다른 객체에 대한 참조가 되는데, 다른 객체를 참조하는 경우 참조 대상을 '프로토타입(prototype)'이라 부른다.

클래스, 프로토타입, 인스턴스의 관계

  • 배열(arr)는 Array클래스의 인스턴스에며 프로토타입에는 다양한 메서드가 존재한다.
    Class > Class.prototype > instance
  1. Class.prototype = Class.prototype 접근
  2. instance.proto = Class.prototype 접근
  3. Class.prototype.constructor = Class 접근
profile
프론트엔드 개발 기록장

0개의 댓글