Расширения

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

Point.prototype.distanceTo = function distanceTo(p) {
    let d1 = Math.pow(this.x - p.x2);
    let d2 = Math.pow(this.y - p.y2);
    return Math.sqrt(d1 + d2);
}

let p1 = new Point(12);
let p2 = new Point(23);
let distance = p1.distanceTo(p2);
//distance is 1.4142

console.log(`distance is ${distance}`);