1

Github

欢迎大家提建议

效果:

class Point {
    x = 0;
    y = 0;

    constructor(_x, _y) {
        if(_x) this.x = _x;
        if(_y) this.y = _y;
    }

    operatorAdd = (b) => {
        const a = this;
        return new Point(a.x + b.x, a.y + b.y);
    }

    operatorMul = (b) => {
        const a = this;
        return new Point(a.x * b, a.y * b);
    }
};

let a = new Point(1, 2), b = new Point(3, 4);

console.log(a + b * 3);

gzz_2000
6 声望0 粉丝