Skip to content

Instantly share code, notes, and snippets.

@ericelliott
Created April 21, 2015 23:51
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 ericelliott/d4006f03b9d6a571803a to your computer and use it in GitHub Desktop.
Save ericelliott/d4006f03b9d6a571803a to your computer and use it in GitHub Desktop.
Inherit from Array
var a = [];
var b = Object.create(a);
b.push('foo');
b[0]; //=> 'foo'
b instanceof Array // => true
b.length // => 1
@ericelliott
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment