Create a gist now

Instantly share code, notes, and snippets.

@ryardley /new_class_syntax.js Secret
Last active Aug 29, 2015

What would you like to do?
var Base = createBase();
// Human < Base
var Human = Base.extend(function(){
return {
init: function(name){
Base.call(this, name);
this.name = name;
this.greeting = 'Hello';
},
makeNoise: function(){
return this.greeting;
}
};
});
// Hippie < Human
var Hippie = Human.extend(function(){
return {
init: function(name){
Human.call(this, name);
this.greeting = 'Hey man!';
},
makePeace: function(){
return 'Peace!';
}
};
});
// Hipster < Hippie
var Hipster = Hippie.extend(function(){
var thought = 'Cafe latte';
return {
init: function(name){
Hippie.call(this, name);
this.greeting = 'Beer me!';
},
makePeace: function(){
return 'Cold drip baby?';
},
setThought: function(value){
thought = value;
},
getThought: function(){
return thought;
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment