#javascript-code-04-baseex.js / js
// Create a new Person class var Person = Base.extend({ // The constructor of the Person class constructor: function( name ) { this.name = name; }, A simple method of the Person class getName: function() { return this.name; } }); // Create a new User class that inherits from the Person class var User = Person.extend({ // Create the User class constructor constructor: function( name, password ) { // which, in turn calls the parent classes' constructor method this.base( name ); this.password = password; }, // Create another, simple, method for the User getPassword: function() { return this.password; } });
(C) Æliens 20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.