Last active
August 31, 2016 20:06
-
-
Save vitkarpov/11f942d12a57db4cd7c40817c4b7ba45 to your computer and use it in GitHub Desktop.
JavaScript Array in essential
This file contains hidden or 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 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