Skip to content

Instantly share code, notes, and snippets.

@hyperqube
Created July 24, 2012 15:30
Show Gist options
  • Save hyperqube/3170678 to your computer and use it in GitHub Desktop.
Save hyperqube/3170678 to your computer and use it in GitHub Desktop.
var tom = Person.create({
name: "Tom Dale",
helloWorld: function() {
this.say("Hi my name is " + this.get('name'));
}
});
tom.helloWorld() // alerts "Hi my name is Tom Dale"
var yehuda = Person.create({
name: "Yehuda Katz",
say: function(thing) {
var name = this.get('name');
this._super(name + " says: " + thing);
}
});
// Subclassing
var LoudPerson = Person.extend({
say: function(thing) {
this._super(thing.toUpperCase());
}
});
//Reopening Classes and Instances
Person.reopen({
isPerson: true
});
Person.create().get('isPerson') // true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment