<SCRIPT LANGUAGE="JavaScript"> <!-- var harogi = new Object(); //harogi 패키지 만듬 harogi.MyClass = function(){ //harogi.MyClass생성자 var name = ""; var id = ""; } harogi.MyClass.prototype.setValue = function(name, id){ this.name = name; this.id = id; } harogi.MyClass.prototype.getName = function(){ return this.name; } harogi.MyClass.prototype.getId = function(){ return this.id; } var mem1 = new harogi.MyClass(); mem1.setValue("홍길동", "hong"); document.write(mem1.getName()); document.write(mem1.getId()); ////////////////////////////////////// MyClass = function(){ var name = ""; var id = ""; } MyClass.prototype.setValue = function(name, id){ this.name = name; this.id = id; } MyClass.prototype.getName = function(){ return this.name; } MyClass.prototype.getId = function(){ return this.id; } var mem2 = new MyClass(); mem2.setValue("임꺽정", "im"); document.write(mem2.getName()); document.write(mem2.getId()); ///////////////////////////////////////// harogi.newClass = {}; //패키지 정의 harogi.newClass.MyClass = function(){ var name = ""; var id = ""; } harogi.newClass.MyClass.prototype.setValue = function(name, id){ this.name = name; this.id = id; } harogi.newClass.MyClass.prototype.getName = function(){ return this.name; } harogi.newClass.MyClass.prototype.getId = function(){ return this.id; } var mem3 = new harogi.newClass.MyClass(); mem3.setValue("임꺽정", "im"); document.write(mem3.getName()); document.write(mem3.getId()); //--> </SCRIPT> |