| Group | Methods |
|---|---|
| Trigonometry (radians) | sin cos tan asin acos atan atan2(y, x), hyperbolic sinh cosh tanh asinh acosh atanh |
| Rounding | round floor ceil trunc, fround (32-bit), f16round (16-bit) |
| Powers and logs | pow sqrt cbrt hypot exp expm1 log log1p log2 log10 |
| Other | abs sign max min random clz32 imul, sumPrecise (Floating-Point Pitfalls) |
for (const x of [2.5, -2.5, -2.7]) console.log(x, Math.round(x), Math.floor(x), Math.trunc(x));
const randomInt = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min; // inclusive
const clamp = (x, lo, hi) => Math.min(Math.max(x, lo), hi);
console.log(randomInt(1, 6) <= 6, clamp(140, 0, 100), Math.hypot(3, 4), Math.max(), Math.cbrt(-27));2.5 3 2 2 -2.5 -2 -3 -2 -2.7 -3 -3 -2 true 100 5 -Infinity -3
Math.round() rounds halves toward +∞, so -2.5 becomes -2. Math.max(...bigArray) throws a RangeError for large arrays (200,000 items in Node.js 25 2,131 ); use reduce(). V8 86,723 's Math.random() is xorshift128+, fast but predictable, so generate tokens with crypto.getRandomValues() (Web Crypto).