ES6 Everyday: New Math Methods
Most of these go over my head, but there’s a lot of fresh new Math methods in ES6:
Sign
- Math.sign(): Returns the sign of a number, indicating whether the number is positive, negative or zero
Truncation and Rounding
- Math.trunc(): Truncates a number, returning only the integer part
- Math.fround(): Rounds to the nearest float
Root
- Math.cbrt(): Returns the cube root of a number
- Math.hypot(): Returns the square root of the sum of squares of its argument
32-bit Manipulation
- Math.clz32(): Returns the number of leading zero bits in the 32-bit binary representation of a number
- Math.imul(): Returns the result of the C-like 32-bit multiplication of the two parameters
Logarithmic
- Math.log10(): Returns the base 10 logarithm of a number
- Math.log2(): Returns the base 2 logarithm of a number
- Math.log1p(): Returns the natural logarithm (base e) of 1 + a number
- Math.expm1(): Returns ex - 1, where x is the argument, and e is the base of the natural logarithms
Trigonometric Functions
- Math.cosh(): Returns the hyperbolic cosine of a number
- Math.sinh(): Returns the hyperbolic sine of a number
- Math.tanh(): Returns the hyperbolic tangent of a number
- Math.acosh(): Returns the hyperbolic arccosine of a number
- Math.asinh(): Returns the hyperbolic arcsine of a number
- Math.atanh(): Returns the hyperbolic arctangent of a number