The new math and Number methods in ES6, I think they are very good. Friends who need them can refer to them.
The new math and Number methods in ES6 are summarized below. Some of them I think are useful
Nunber.isInteger() determines whether it is an integer. It should be noted that 1 and 1.0 will be considered integers
##
console.log(Number.isInteger(1.0))//true console.log(Number.isInteger(1))//true console.log(Number.isInteger("1"))//false console.log(Number.isInteger("1.1"))//false
##
console.log(Math.sign(1))//1 console.log(Math.sign(-1))//-1 console.log(Math.sign(0))//0 console.log(Math.sign(-0))//0 console.log(Math.sign(NaN))//NaN console.log(Math.sign(undefined))//NaN console.log(Math.sign(null))//0
console.log(Math.cbrt(8))//2 Math.hypot()返回所有参数的平方和的平方根 console.log(Math.hypot(4,3))//25再开方结果为5
console.log(2**2) //4 console.log(2**3) //8
The above is the detailed content of An explanation of the new math and Number methods in JavaScript ES6. For more information, please follow other related articles on the PHP Chinese website!