생성자와 new
1. 객체
var person = {}
person.name = 'egoing';
person.introduce = function(){
return 'My name is '+this.name;
}
document.write(person.introduce());
//위 코드는 객체를 만드는 과정에 있어서 분산되어 있어
//중간에 다른 내용이 끼기 쉬움var person = {
'name' : 'egoing',
'introduce' : function(){
return 'My name is '+this.name;
} //{}를 사용해서 grouping하여 가독성도 좋고, 내용이 분산되지 않음
}
document.write(person.introduce());2. 생성자와 new
2-1. 생성자(Contructor)
function Func_name(){}
var name = new Func_name(){}; 2-2. new
2-3. 초기화작업
Last updated