Math.hypot Function (JavaScript)

Returns the square root of the sum of the squares of the arguments.

Syntax

Math.hypot ( value1[, value2[, ...values] );  

Parameters

value1
Required. The first number.

value2
Optional. The second number.

values
Optional. One or more numbers.

Remarks

If any argument is NaN, function returns NaN. If no arguments are provide, the function returns 0.

Example

The following example shows an example of using the Math.hypot function.

Math.hypot(3, 4);  
// Returns 5  

Math.hypot(3, "4");  
// Returns 5  

Math.hypot(3, "four");  
// Returns NaN   

Math.hypot(3, 4, 10);  
// Returns 11.180339887498949  

Requirements

Supported in Microsoft Edge (Edge browser). Also supported in Store apps (Microsoft Edge on Windows 10). See Version Information.
Not supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards, Internet Explorer 11 standards. Not supported in Windows 8.1.