A diagonal is longer than either of its components. Math.hypot combines perpendicular distances without making the caller square each input.
Worked example
console.log(Math.hypot(3, 4));Result
5Implementation notes
Treat the coordinates as lengths in the same unit before combining them. A pixel distance on one axis and a percentage on the other cannot produce a meaningful diagonal until converted.
Try it yourself
Try a three-by-four displacement, then reverse one direction. The length should remain five.
Open the JavaScript example →Editorial date December 6, 2026 · Published December 6, 2026