The Math.hypot()
function returns the square root of the sum of squares of its arguments.
Math.hypot([value1[, value2[, ...]]]) // value1, value2, ... are Numbers.
If no arguments are given, the result is +0.
If at least one of the arguments cannot be converted to a number, the result is NaN.
With one argument, Math.hypot()
returns the same as Math.abs()
.
let a = Math.hypot(3, 4); // 5 console.log(a);//from www . j ava 2 s . com a = Math.hypot(3, 4, 5); // 7.0710678118654755 console.log(a); a = Math.hypot(); // 0 console.log(a); a = Math.hypot(NaN); // NaN console.log(a); a = Math.hypot(3, 4, 'test'); // NaN, +'test' => NaN console.log(a); a = Math.hypot(3, 4, '5'); // 7.0710678118654755, +'5' => 5 console.log(a); a = Math.hypot(-3); // 3, the same as Math.abs(-3) console.log(a);