Math.hypot([number1, number2, ... number_n]);
Parameters or Arguments
number1, number2, … number_n Optional. The numbers that will be used in the calculation.
The hypot() feature returns the rectangular root after summing the squares of the parameters provided:
√ number12 + number22 + number_n2
Math is a placeholder object that contains mathematical features and constants of which hypot() is one of these functions. You can use the hypot() characteristic to calculate the hypotenuse of a right angled triangle the place a and b are the lengths of the legs of the triangle: hypotenuse = √ a2 + b2
console.log(Math.hypot(1)); console.log(Math.hypot(2, 3)); console.log(Math.hypot(8, 1, -5));
In this example, we have invoked the hypot() function the use of the Math class.
We have written the output of the hypot() function to the web browser console log, for demonstration purposes, to exhibit what the hypot() function returns.
The following will be output to the internet browser console log:
1 3.6055512754639896 9.486832980505138
In this example, the first output to the console log lower back 1 which the end result of the calculation √12.
The second output to the console log again 3.6055512754639896 which the result of the calculation √22 + 32.
The 0.33 output to the console log lower back 9.486832980505138 which the end result of the calculation √82 + 12 + -52.