// Implementation of an Array class

class Arr {
    constructor() {
        this.length = 0;
        this.data = {};
    }

    get(index) {
        return this.data[index];
    }

    push(item) {
        this.data[this.length] = item;
        this.length += 1;
    }

    pop() {
        const lastItem = this.data[this.length - 1];
        delete this.data[this.length - 1];
        this.length -= 1;
        return lastItem;
    }

    delete(index) {
        const item = this.data[index];
        this.shiftItems(index);
        return item;
    }

    shiftItems(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 -= 1;
    }
}

// Example usage:
const arr = new Arr();
console.log(arr.get(0));  // undefined
arr.push("Hi");
arr.push("you");
arr.push("are");
arr.push("!");
arr.push("!");
console.log(arr.pop());   // "!"
arr.push("nice");
console.log(arr);
console.log(arr.delete(3));  // "nice"
console.log(arr);

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: