Compute Root of Sum of Squares
Computes the square root of the sum of squares of its arguments, that is:
Examples
Filter
console.log(Math.hypot(3, 4));
// expected output: 5
console.log(Math.hypot(5, 12));
// expected output: 13
console.log(Math.hypot(3, 4, 5));
// expected output: 7.0710678118654755
console.log(Math.hypot(-5));
// expected output: 5
Math.hypot(3, 4); // 5
Math.hypot(3, 4, 5); // 7.0710678118654755
Math.hypot(); // 0
Math.hypot(NaN); // NaN
Math.hypot(3, 4, 'foo'); // NaN, +'foo' => NaN
Math.hypot(3, 4, '5'); // 7.0710678118654755, +'5' => 5
Math.hypot(-3); // 3, the same as Math.abs(-3)