API Math

Nombres

Number.NaN = NaN;
Number.NEGATIVE_INFINITY = -Infinity;
Number.POSITIVE_INFINITY = Infinity;
Number.EPSILON = 2.220446049250313e-16;
Number.MIN_SAFE_INTEGER = -9007199254740991;
Number.MAX_SAFE_INTEGER = 9007199254740991;
// Plus grand nombre
Number.MAX_VALUE = 1.7976931348623157e+308;

// Plus petit nombre
Number.MIN_VALUE = 5e-324;

Constantes

Math.PI = 3.141592653589793;
Math.E = 2.718281828459045;
Math.LN10 = 2.302585092994046;
Math.LN2 = 0.6931471805599453;
Math.LOG10E = 0.4342944819032518;
Math.LOG2E = 1.4426950408889634;
Math.SQRT2 = 1.4142135623730951;
Math.SQRT1_2 = 0.7071067811865476;

Mini - Maxi

// Minimum
Math.min(5, 11 , 3, 4) = 3;

// Maximum
Math.max(5, 11 , 3, 4) = 11;

Trigonométrie

Math.cos(1.047) = 0.5001710745970701;
Math.acos(0.5) = 1.0471975511965979;
Math.sin(1.047) = 0.8659266112878228;
Math.asin(0.5) = 0.5235987755982989;
Math.tan(1.047) = 1.7312608730630803;
Math.atan(0.5) = 0.4636476090008061;
Math.atan2(1, 2) = 0.4636476090008061;

Hyperbolique

Math.cosh(1) = 1.5430806348152437;
Math.acosh(1.5) = 0.9624236501192069;

Math.sinh(1) = 0.881373587019543;
Math.asinh(0.5) = 0.48121182505960347;

Math.tanh(1) = 0.7615941559557649;
Math.atanh(0.5) = 0.5493061443340548;

Arrondi

Math.ceil(2.51) = 3;
Math.floor(2.51) = 2;
Math.round(2.51)= 3;
Math.trunc(2.51)= 2;

Math.ceil(-2.51) = -2;
Math.floor(-2.51) = -3;
Math.round(-2.51)= -3;
Math.trunc(-2.51)= -2;

Math.fround(2.51)= 2.509999990463257;

Signes

Math.abs(-5.3) = 5.3;
Math.sign(-5.3) = -1;

Puissances / Racines

//Puissance : 2 puissance 5
Math.pow(2, 5) = 32;

// Racine carrée
Math.sqrt(144) = 12;

// Racine cubique
Math.cbrt(27) = 3;

Logarithme / Exponentielle

Math.log(7.39) = 2.0001277349601105;
Math.log10(100) = 2;
Math.log2(16) = 4;
Math.log1p(6.39) = 2.0001277349601105;

Math.exp(2) = 7.38905609893065;
Math.expm1(2) = 6.38905609893065;

Autres

Math.random() = 0.16065355184033425;
Math.clz32(58) = 26;
Math.hypot(3, 4) = 5;
Math.imul(3, 4) = 12;