ES6中数值的扩展总结

二进制与八进制的表示

let n1 = 0b0101;
let n2 = 0o77;
let n3 = 0x12;
//n1 = 5
//n2 = 63
//n3 = 18

Number

Number.parseInt()
Number.parseFloat()
Number.isInteger()
Number.EPSILON
Number.EPSILON.toFixed(20)
Number.isSafeInteger()

Math

Math.trunc(x)//去掉小数部分
Math.cbrt(x)//立方根
Math.hypot(a,b,c,...)//对所有数据求平方然后开方
Math.expm1(x)//e^x -1
Math.log1p(x)//log(1+x)
Math.log10(x)
Math.log2(x)
Math.sinh(x)Math.cosh(x)Math.tanh(x)
Math.asinh(x)Math.acosh(x)Math.atanh(x)
Math.pow(x, y)

你可能感兴趣的:(ES6,es6)