객체 생성 패턴 3가지
리터럴(literal) 방식
var 인스턴스 = {
프로퍼티1: 초깃값,
프로퍼티2: 초깃값,
메서드1: function(){
},
메서드2: function(){
}
}함수 방식
프로토타입 방식
Last updated
var 인스턴스 = {
프로퍼티1: 초깃값,
프로퍼티2: 초깃값,
메서드1: function(){
},
메서드2: function(){
}
}Last updated
function 클래스이름(){
this.프로퍼티1 = 초깃값;
this.프로퍼티2 = 초깃값;
this.메서드 = function(){
},
this.메서드 = function(){
}
}
var 인스턴스 = new 클래스 이름();function 클래스이름(){
this.프로퍼티1 = 초깃값;
this.프로퍼티2 = 초깃값;
}
클래스이름.prototype.메서드 = function(){};
클래스이름.prototype.메서드 = function(){};
var 인스턴스 = new 클래스 이름();