Calculates the length/magnitude of the given vector.

Type signature

([x, y]: [number, number]) => number

Examples

length([3, 5]);
// ⇒ Math.sqrt(3 * 3 + 5 * 5)
Try in REPL

Questions

  • How to compute the length of a vector?
  • How to compute the magnitude of a vector?

TypeScript sourceJavaScript source