Skip to content

Instantly share code, notes, and snippets.

@Drag13
Created September 20, 2018 16:17
Show Gist options
  • Save Drag13/a11b5d77eb4babf91a9960386ec99d53 to your computer and use it in GitHub Desktop.
Save Drag13/a11b5d77eb4babf91a9960386ec99d53 to your computer and use it in GitHub Desktop.
function MyArray(arr) {
const _arr = arr || [];
this.push = function push(value) {
console.log('prepush');
_arr.push(value)
console.log('postpush');
}
this.get = function getByIndex(index) {
return _arr[index];
}
}
var arr = new MyArray();
arr.push('5');
console.log(arr.get(0));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment