class Point {
    x;
    y;
}

class Point2 {
    #x;
    #y;

    constructor(x, y) {
        this.#x = x;
        this.#y = y;
    }

    get x() {
        return this.#x;
    }

    get y() {
        return this.#y;
    }

    moveBy(dx, dy) {
        this.#x += dx;
        this.#y += dy;
        return this;
    }

    toString() {
        return `Point { x: ${this.#x}, y: ${this.#y} }`;
    }
}

const ap2 = [];
for (let i = 0; i < 5; ++i) {
    ap2.push(new Point2(i * 5, i* 10));
}
for (const p2 of ap2) {
    p2.moveBy(1, -1).moveBy(2, -2).moveBy(0, 0);
}
for (let p2 of ap2) {
    console.log(p2.toString());
}


/*
const ap = [];
for (let i = 0; i < 5; ++i) {
    const p = new Point();
    p.x = i * 5;
    p.y = i * 10;
    ap.push(p);
}
for (let p of ap) {
    console.log(p);
}
*/

Embed on website

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