Open this example in the interactive library
Source code
class Point {
constructor(x, y) {
Object.assign(this, { x, y });
}
static origin() {
return new Point(0, 0);
}
}
console.log(Point.origin());
Sample output
Point { x: 0, y: 0 }