Skip to content

Instantly share code, notes, and snippets.

@EnoF
EnoF / gist:8941149
Created February 11, 2014 18:37
Super and Constructor!
var Animal = clazz(function Animal(){
this.private = {
name: 'animal'
};
this.public = {
sayHello: function sayHello(){
return 'Hi, my name is ' + this.private.name + '!';
}
};
@EnoF
EnoF / gist:8940949
Created February 11, 2014 18:27
Protected in EnoFJS
var Animal = clazz(function Animal(){
this.protected = {
name: 'animal'
};
this.public = {
sayHello: function sayHello(){
return 'Hi, my name is ' + this.protected.name + '!';
}
};
});
@EnoF
EnoF / gist:8940237
Last active August 29, 2015 13:56
Override in EnoFJS
var Animal = clazz(function Animal(){
this.private = {
name: 'animal'
};
this.public = {
sayHello: function sayHello(){
return 'Hi, my name is ' + this.private.name + '!';
}
};
});
@EnoF
EnoF / gist:8930612
Last active August 29, 2015 13:56
Overriding the Bad way
function Animal(){}
Animal.prototype = {
name: 'animal',
sayHello: function sayHello(){
return 'Hi, my name is ' + this.name + '!';
}
};
function Dog(){}
@EnoF
EnoF / gist:8930564
Last active August 29, 2015 13:56
EnoFJS Inheritance
var Animal = clazz(function Animal(){
this.private = {
name: 'animal'
};
this.public = {
sayHello: function sayHello(){
return 'Hi, my name is ' + this.private.name + '!';
}
};
});