Skip to content

Instantly share code, notes, and snippets.

@revolunet
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save revolunet/8792763 to your computer and use it in GitHub Desktop.
Save revolunet/8792763 to your computer and use it in GitHub Desktop.
JS minimal class implementation
// from http://raganwald.com/2014/01/19/prototypes-are-not-classes.html
var MovieCharacterClass = {
create: function create (firstName, lastName) {
var mc = Object.create(MovieCharacterClass.prototype);
mc.firstName = firstName;
mc.lastName = lastName;
return mc;
},
prototype: {
fullName: function fullName () {
return this.firstName + " " + this.lastName;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment