Three.js
Working with vectors
// Initialization:
const a = new THREE.Vector2(1, 2);
const b = new THREE.Vector3(2, 2);
const c = new THREE.Vector2(); // default constructor arguments are (0, 0)
// d = a + b;
const d = new THREE.Vector2();
d.copy(a); // copy the values of a into d
d.add(b); // add b to d
const cd = c.distanceTo(d);
// Important to note:
// add mutates the values of the current vector