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

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