JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://rawgit.com/sapienlab/lang-def/master/def.js"></script>
<h1>See the console</h1>
JavaScript
var Point = def({
new: function (x, y) {
this.x = x;
this.y = y;
},
distance: function (p) {
return Math.sqrt(
Math.pow(p.x - this.x, 2) +
Math.pow(p.y - this.y, 2)
)
}
})
console.log(Point)
var a = new Point(2, 4)
var b = new Point(5, -6)
console.log('a', a)
console.log('b', b)
console.log(a.distance(b))
// -> 10.44030650891055