Created
May 11, 2017 22:21
-
-
Save rkaw92/0207f287fe8fb0a795c744dd356a968c to your computer and use it in GitHub Desktop.
Prototypal inheritance
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
function BucketCollector() { | |
} | |
BucketCollector.prototype.addToBucket = function addToBucket(item) { | |
this.items.push(item); | |
}; | |
BucketCollector.prototype.items = []; | |
var a = new BucketCollector(); | |
var b = new BucketCollector() | |
a.addToBucket('thing'); | |
b.addToBucket('otherThing'); | |
console.log('a.items:', a.items); | |
console.log('b.items:', b.items); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment