ES6

.sign(x)

Returns

  • -1 if x is a negative number (including -Infinity).
  • 0 if x is zero4.
  • +1 if x is a positive number (including Infinity).
  • NaN if x is NaN or not a number.
console.log(Math.sign(-8)) // -a
console.log(Math.sign(3)) // 1
console.log(Math.sign(0)) // 0
console.log(Math.sign(NaN)) // NaN
console.log(Math.sign(-Infinity)) // -1
console.log(Math.sign(Infinity)) // 1

.trunc(x)

console.log(Math.trunc(3.1)) // 3
console.log(Math.trunc(3.9)) // 3
console.log(Math.trunc(-3.1)) // 3
console.log(Math.trunc(-3.9)) // 3

.cbrt(x)

Returns the cube root of x:

console.log(Math.cbrt(8)) // 2
console.log(Math.cbrt(27)) // 3