JavaScript (ES2026) reference · Math Methods and Constants
JavaScript Math.hypot() Method
Return the square root of the sum of squares of its arguments, e.g. the length of a vector or a diagonal.
JavaScript (ES2026) Since ES2015
Syntax
Math.hypot(value1, value2, /* …, */ valueN)
Parameters
| Parameter | Description |
|---|---|
values |
Numbers. |
Return value
A number.
Examples
console.log(Math.hypot(3, 4), Math.hypot(1, 2, 2));
Output
5 3
const w = 1920, h = 1080;
console.log("diagonal in pixels:", Math.round(Math.hypot(w, h)));
Output
diagonal in pixels: 2203
Version history
| Version | Change |
|---|---|
| JavaScript ES2015 | Added |
Related
Math.sqrt()· Return the square root of a number, or NaN for negative numbers. Use it for distances and the Pythagorean theorem.- JavaScript Math · tutorial
- JavaScript Numbers · tutorial