The methods of the math object are: 1. round(), used for rounding; 2. ceil(), which can be rounded up; 3. floor(), which can be rounded down; 4. pow() , can return the y power of x; 5. sqrt(), can return the square root of a number; 6. max(); 7. min(); 8. random(); 9. abx(); 10. sin( ); 11. asin(); 12. cos(); 13. acos(); 14. tan(); 15. exp().
The operating environment of this tutorial: windows7 system, jquery3.6 version, Dell G3 computer.
jquery Math object method
Rounding Math.round()
Math.round() //四舍五入,去最接近的整数 Math.round(2.2) //--2 Math.round(2.5) //--3
Round up Math.ceil()
Math.ceil() //上取整 Math.ceil(2.2) //--3 Math.ceil(2.5) //--3
Round down Math.floor()
Math.floor() //下取整 Math.floor(2.2) //--2 Math.floor(2.5) //--2
Returns the y power of xMath.pow(x,y)
Math.pow(x,y) //返回x的y次幂 Math.pow(2,2) //--4 Math.round(2,3) //--8
Returns the square root of xMath.sqrt()
Math.sqrt(x) Math.sqrt(4) //2 Math.sqrt(9) //3 Math.sqrt(6) //2.449489742783178
Return the highest value in x,y,z,…,n Math.max(x,y,z,…n)
Math.max(x,y,z,.....n) //返回 x,y,z,...,n 中的最高值 //Math.max(2,3,4,6,5)--6
Return the minimum value in x,y,z,…,n Math.min(x,y,z,…n)
Math.min(x,y,z,.....n) //返回 x,y,z,...,n中的最小值 //Math.max(2,3,4,6,5)--2
Returns a random number between 0 ~ 1 Math.random()
Math.random() //返回 0 ~ 1 之间的随机数 //返回0-100之间的随机数 x=100 y=0 //parseInt(Math.random()*(x - y + 1) + y)
Returns the absolute value of xMath.abx( x)
Math.abx(x) //返回 x 的绝对值 Math.abx(2) //--2 Math.abx(-2) //--2
Returns the sine of xMath.sin(x)
Math.sin(x) //返回 x 的正弦值 Math.sin(1) //0.8414709848078965
Returns the arcsine of xMath.asin(x)
Math.asin(x) //返回 x 的反正弦值 Math.asin(-2); // NaN Math.asin(-1); // -1.5707963267948966 (-pi/2) Math.asin(0); // 0 Math.asin(0.5); // 0.5235987755982989 Math.asin(1); // 1.570796326794897 (pi/2) Math.asin(2); // NaN //对于小于 -1 或大于 1 的参数值,Math.asin 返回 NaN。
Returns the cosine of x Math.cos(x)
Math.cos(x) Math.cos(1) //0.5403023058681398 Math.cos(-1) //0.5403023058681398
Returns the inverse cosine of x Math.acos(x)
Math.acos(-1) //3.141592653589793 Math.acos(-2) //NaN Math.acos(0) //1.5707963267948966 Math.acos(1) //0 //对于小于 -1 或大于 1 的参数值,Math.acos 返回 NaN。
Returns the tangent of the angle Math.tan()
Math.tan() Math.tan(15) //-0.8559934009085188
Returns E The exponent of the power of
The above is the detailed content of What are the methods of math object in jquery. For more information, please follow other related articles on the PHP Chinese website!