강의

멘토링

커뮤니티

인프런 커뮤니티 질문&답변

rudals8920님의 프로필 이미지
rudals8920

작성한 질문수

자바스크립트 중고급: 엔진 핵심

6. this와 prototype, this로 인스턴스 참조, this와 prototype, prototype 메소드 직접 호출

질문드려도 될까요 선생님..

작성

·

213

0

function Book(){
  console.log(this.point)
}

// Book.prototype.setPoint = function(){
//   this.point = 100;
// }

// Book.prototype.getPoint = function(){
//   this.setPoint();
//   console.log(this.point)
// }
Book.prototype = {
  constructor: Book,
  setPoint: function(){
    this.point = 100;
  },
  getPoint: function(){
    this.setPoint();
    console.log(this.point)
  }
}


var obj = new Book();
obj.getPoint()
보다보니 class와 비슷하게 생긴거 같은데
클레스가 이와같은 원리로 작동한다고 보면 될까요??

답변

답변을 기다리고 있는 질문이에요
첫번째 답변을 남겨보세요!
rudals8920님의 프로필 이미지
rudals8920

작성한 질문수

질문하기