딘 에드워즈가 만든 Base 라이브러리로 클래스를 생성하고 상속하는 간단한 예
딘 에드워즈의 웹사이트 : http://dean.edwards.name/
A Base Class for Javascript Inheritance : http://dean.edwards.name/weblog/2006/03/base/
ie7-js : http://code.google.com/p/ie7-js/
base2 (A standards-bases javascript Library) : http://code.google.com/p/base2/
cssQuery() : http://dean.edwards.name/my/cssQuery/
//새 Person 클래스를 만든다.
var Person = Base.extend({
// Person 클래스 생성자
constructor: function( name ) {
this.name = name;
},
//Person 클래스의 간단한 메서드
getName: function() {
return this.name;
}
});
// Person 클래스를 상속하는 새 User 클래스를 만든다.
var User = Person.extend({
// User 클래스의 생성자를 만든다.
constructor: function( name, password ) {
// 부모 클래스의 생성자 메서드를 호출한다.
this.base( name );
this.password = password;
},
// User 클래스에 간단한 메서드를 추가한다.
getPassword: function() {
return this.password;
}
});
Posted by 홍반장




