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

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

Math.hypot(value1, value2, /* …, */ valueN)

Parameters

ParameterDescription
values Numbers.

Return value

A number.

Examples

Vector lengthsTry it yourself
console.log(Math.hypot(3, 4), Math.hypot(1, 2, 2));

Output

5 3
Screen diagonalTry it yourself
const w = 1920, h = 1080;
console.log("diagonal in pixels:", Math.round(Math.hypot(w, h)));

Output

diagonal in pixels: 2203

Version history

VersionChange
JavaScript ES2015Added

Was this page helpful?