/daClass

Simple inheritance system that takes advantage of the Javascript's prototype chain

Primary LanguageJavaScript

#daClass

Creating a simple "class":

var Animal = daClass({
	//properties
	name: '',

	// Constructor
	init: function(name){
		this.name = name;
	},

	getName: function(){
		return this.name;
	}
});


var Bird = daClass(Animal, {
	// Constructor
	init: function(name){
		this.super(arguments);
		this.name = "Hi " + this.name ;
	}
});

var bird1 = new Bird('Pigeon');
console.log( bird1.getName() ); // Hi Pigeon