Created
April 21, 2015 23:51
-
-
Save ericelliott/d4006f03b9d6a571803a to your computer and use it in GitHub Desktop.
Inherit from Array
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
var a = []; | |
var b = Object.create(a); | |
b.push('foo'); | |
b[0]; //=> 'foo' | |
b instanceof Array // => true | |
b.length // => 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem - assigning to the array using square bracket notation does not increment the
length
property. We'd need to add a setter to do that.