Skip to content

Instantly share code, notes, and snippets.

@vitkarpov
Last active August 31, 2016 20:06
Show Gist options
  • Save vitkarpov/11f942d12a57db4cd7c40817c4b7ba45 to your computer and use it in GitHub Desktop.
Save vitkarpov/11f942d12a57db4cd7c40817c4b7ba45 to your computer and use it in GitHub Desktop.
JavaScript Array in essential
function MyArray() {
this._index = 0;
}
MyArray.prototype.push = function(v) {
this[this._index++] = v;
}
var arr = new MyArray();
arr.push(1);
arr.push(2);
// 1
console.log(arr[0])
// 2
console.log(arr[1]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment