Skip to content

Instantly share code, notes, and snippets.

@EnoF
Last active August 29, 2015 13:56
Show Gist options
  • Save EnoF/8930564 to your computer and use it in GitHub Desktop.
Save EnoF/8930564 to your computer and use it in GitHub Desktop.
EnoFJS Inheritance
var Animal = clazz(function Animal(){
this.private = {
name: 'animal'
};
this.public = {
sayHello: function sayHello(){
return 'Hi, my name is ' + this.private.name + '!';
}
};
});
var Dog = clazz(function Dog(){
this.extend = 'Animal';
});
var dog = new Dog();
dog instanceof Animal; //True
dog.sayHello(); //Hi, my name is animal!
dog.name; //undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment