Home >Web Front-end >Front-end Q&A >What are the math methods in JavaScript?

What are the math methods in JavaScript?

青灯夜游
青灯夜游Original
2021-04-09 17:18:173486browse

The methods of the Math object are: abs(), acos(), asin(), atan(), cos(), floor(), log(), max(), min(), pow( ), random(), round(), sin(), sqrt(), tan(), exp(), etc.

What are the math methods in JavaScript?

The operating environment of this tutorial: Windows 7 system, ECMAScript version 5, Dell G3 computer.

Math objects are used to perform mathematical tasks.

Methods of Math object

  • abs(x): Returns the absolute value of the number.

  • acos(x): Returns the arc cosine of the number.

  • #asin(x): Returns the arcsine value of the number.

  • atan(x): Returns the arctangent of x as a value between -PI/2 and PI/2 radians.

  • atan2(y,x): Returns the angle from the x-axis to the point (x,y) (between -PI/2 and PI/2 radians).

  • #ceil(x): Round up the logarithm.

  • cos(x): Returns the cosine of the number.

  • #exp(x): Returns the exponent of e.

  • #floor(x): Round down the logarithm.

  • #log(x): Returns the natural logarithm of the number (base is e).

  • max(x,y): Returns the highest value between x and y.

  • min(x,y): Returns the lowest value between x and y.

  • pow(x,y): Returns x raised to the y power.

  • random(): Returns a random number between 0 ~ 1.

  • #round(x): Round the number to the nearest integer.

  • #sin(x): Returns the sine of the number.

  • sqrt(x): Returns the square root of the number.

  • tan(x): Returns the tangent of the angle.

  • #toSource(): Returns the source code of the object.

  • #valueOf(): Returns the original value of the Math object.

[Recommended learning: javascript advanced tutorial]

The above is the detailed content of What are the math methods in JavaScript?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn