class Vector { constructor(x = 0, y = 0) { this.x = x; this.y = y; } length() { return Math.sqrt(this.x * this.x + this.y * this.y); } angle() { return Math.atan2(this.y, this.x); } distance(v2 = this) { return new Vector(this.x - v2.x, this.y - v2.y).length(); } toString() { return `vector(${this.x}, ${this.y})`; } } const vect = new Vector(3, 4); console.log(vect.length()); // 5