bhylu.com

Advertisements

JS Math Reference

Combine Math functions to express a calculation. Hypot calculates a distance without manually adding squared terms.

Where to run this

This example uses the JavaScript console playground. Select Run to execute it; the example does not run on this lesson page.

A practical example

JavaScript

const width = 3;
const height = 4;
console.log(Math.hypot(width, height));

What happens

The diagonal distance is 5.