
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
What is the use of Math.hypot() function in JavaScript?
Math.hypot()
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.
syntax
Math.hypot(arg1, arg2,....);
Example
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>
Output
25 NaN
This method even accepts negative values as arguments and tries to give the square root of some of their squares as output.
Example
<html> <body> <script> document.write(Math.hypot(-7, -24)); document.write("</br>") document.write(Math.hypot(-3, -4)) </script> </body> </html>
Output
25 5
This method can take multiple values, more than two, and tries to give the square root of some of their squares.
Example
<html> <body> <script> document.write(Math.hypot(1, 2, 3)); </script> </body> </html>
Output
3.74165738677
- Related Articles
- 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 eval function?
- What is the use of return statement inside a function in JavaScript?
- What is the use of ()(parenthesis) brackets in accessing a function in JavaScript?
- What is the use of FIND_IN_SET () function in MySQL?
- What is the use of LOCATE() function in MySQL?
- What is the use of pheatmap function in R?
- What is the use of the map function in Python?
- What is the use of Atomics in JavaScript?
- What is the use of OBJECT.assign() in javascript?
- What is the use of Map in JavaScript?
- What is the use of window.location in javascript?
- What is the use of sentry in javascript?
- What is the use of MySQL UNHEX() function?

Advertisements