Created
November 20, 2012 16:09
-
-
Save esgy/4118871 to your computer and use it in GitHub Desktop.
js: prototype pattern
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
// No need for capitalization as it's not a constructor | |
var someCar = { | |
drive: function() {}; | |
name: 'Mazda 3' | |
}; | |
// Use Object.create to generate a new car | |
var anotherCar = Object.create(someCar); | |
anotherCar.name = 'Toyota Camry'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment