- Related Questions & Answers
- What is the use of JavaScript eval function?
- What is the use of apply() function in JavaScript?
- What is the use of Math.imul( ) Function in JavaScript?
- What is the use of JavaScript cookies?
- What is the use of return statement inside a function in JavaScript?
- What is the use of Map in JavaScript?
- What is the use of Atomics in JavaScript?
- What is the use of OBJECT.assign() in javascript?
- What is the use of window.location in javascript?
- What is the use of sentry in javascript?
- What is the use of ()(parenthesis) brackets in accessing a function in JavaScript?
- What is the use of MySQL FROM_UNIXTIME() function?
- What is the use of MySQL GET_FORMAT() function?
- What is the use of MySQL LAST_INSERT_ID() function?
- What is the use of MySQL CONCAT_WS() function?

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

**Math.Hypot()** method is used to find the square root of the sum of the squares of the elements that are passed to it as arguments. This method is actually used to find the hypotenuse of a right-angle triangle whose sides are passed as arguments into it.

Math.hypot(arg1, arg2,....);

In the following example, sides of a right-angle triangle are passed to find the hypotenuse. If any value is can't be converted to a number then **NaN **will be displayed as output.

<html> <body> <script> document.write(Math.hypot(7, 24)); document.write("</br>"); document.write(Math.hypot(7, "hi")); </script> </body> </html>

25 NaN

This method even accepts negative values as arguments and tries to give the square root of some of their squares as output.

<html> <body> <script> document.write(Math.hypot(-7, -24)); document.write("</br>") document.write(Math.hypot(-3, -4)) </script> </body> </html>

25 5

This method can take multiple values, more than two, and tries to give the square root of some of their squares.

<html> <body> <script> document.write(Math.hypot(1, 2, 3)); </script> </body> </html>

3.74165738677

Advertisements