Maxbianhao / def.js

Simple Ruby-style inheritance for JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simple Ruby-style inheritance for JavaScript

Example

def ("Person") ({
	init: function(name){
		this.name = name;
	},
	
	speak: function(text){
		alert(text || "Hi, my name is " + this.name);
	}
});

def ("Ninja") << Person ({
	init: function(name){
		this._super();
	},
	
	kick: function(){
		this.speak("I kick u!");
	}
});

var ninjy = new Ninja("JDD");

ninjy.speak();
ninjy.kick();

About

Simple Ruby-style inheritance for JavaScript

License:MIT License


Languages

Language:JavaScript 100.0%