JSFiddle - React, Tailwind, and code Playground

by koenj

JavaScript

function Point(x, y) {
    this.x = x;
    this.y = y;
}
Point.prototype.dist = function() {
    return Math.sqrt((this.x * this.x) + (this.y * this.y));
};
Point.prototype.toString = function() {
    return "(" + this.x + ", " + this.y + ")";
};


var p = new Point(1,2);
alert(p.toString());