class myArray{
constructor(){
this.data = {};
this.length = 0;
}
get(index){
return this.data[index]
}
push(item){
this.data[this.length] = item;
this.length++;
}
delete(index){
this._shiftItem(index)
}
_shiftItem(index){
for(let i=index; i<this.length; i++){
this.data[index] = this.data[index+1]
}
delete this.data[this.length-1]
this.length--;
}
}
const array1 = new myArray();
array1.push('hello');
array1.push('world');
array1.push('yonas');
console.log('original: ', array1);
array1.delete(1);
console.log('final: ', array1);