var classBuilder = function(){
var protolist = [];
var theconst = function(){}
return {
addproto : function(name,func){
protolist.push({name:name,func:func})
return this;
},
setconst : function(func){
theconst = func
return this;
},
build : function(){
var returnClass = theconst;
returnClass.constructor = theconst;
protolist.forEach(v => returnClass.prototype[v.name] = v.func);
return returnClass;
}
}
};

var Student = classBuilder().setconst(function(name,school){
this.name = name;
this.school = school;
return this;
}).addproto('introduce',function(){
console.log('my name is ' + this.name + ' and attending ' + this.school + ' university');
}).build();

var myStudent = new Student('john doe','pooe');
myStudent.introduce();


디자인 패턴 조또 모르는데 이렇게 짜면 욕먹음?