Array Implementation

Run Settings
LanguageJavaScript
Language Version
Run Command
class MyArray{ constructor(){ this.length=0; this.data={}; } get(index){ return this.data[index]; } push(data){ this.data[this.length]=data; this.length++; return this.data; } pop(){ const lastItem=this.data[this.length-1]; delete this.data[this.length-1]; this.length--; return lastItem; } deleteAtIndex(index){ const item= this.data[index]; this.shiftArray(index); return item; } shiftArray(index){ for(let i=index; i<this.length-1; i++){ this.data[i]=this.data[i+1]; } delete this.data[this.length-1]; this.length--; } } const myArray = new MyArray(); myArray.push('hi'); myArray.push('you'); myArray.push('!'); myArray.pop(); myArray.deleteAtIndex(0); myArray.push('are'); myArray.push('nice'); myArray.shiftArray(0); console.log(myArray);
Editor Settings
Theme
Key bindings
Full width
Lines