Math
is a built-in object in JavaScript that contains different methods and properties used to perform mathematical operations. It contains a hypot()
function, which is used to compute the magnitude of a specified number. It is short for hypotenuse.
Math.hypot(param1, param2, ...paramN);
param1, param2, ... paramN
: These are the input parameters, which can be of any number ranging from 0 to N. They are of the Number
type.
Number
in JavaScript is a 64-bit double-precision value that is the same asdouble
in C# or Java.
Number
: It returns the square root of the sum of squares of its arguments. It is of the Number
type.
NaN
: The function returns this if any of the input parameters are not a Number
.
console.log("hypot() = " + Math.hypot());console.log("hypot(-2) = " + Math.hypot(-2));console.log("hypot(2,3,'4') = " + Math.hypot(2,3,'4'));console.log("hypot(NaN) = " + Math.hypot(NaN));console.log("hypot(2,3,'educative') = " + Math.hypot(2,3,'educative'));console.log("hypot(2,3,4) = " + Math.hypot(2,3,4));