Last active
August 29, 2015 13:56
-
-
Save revolunet/8792763 to your computer and use it in GitHub Desktop.
JS minimal class implementation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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