JavaScript – Objects – Math Object

The Math object’s method allow the programmer to perform mathematical calculations.
An object’s method’s are called by writing the name of the object followed by a dot operator and the name of the method.
Following the method name is the argument/s to the method.

Some math objects:

Method Description
abs(x) absolute value of x
ceil(x) rounds x to the smallest integer not less than x
cos(x) trigonometric cosine of x (x in radians)
exp(x) exponential method of x^e
floor(x) rounds x to the largest integer not greater than x
log(x) natural logarithm of x (base e)
max(x,y) larger value of x and y
min(x,y) smaller value of x and y
pow(x,y) x raised to the power of y (x^y)
round(x) rounds x to the closest integer
sin(x) trigonometric sine of x (x in radians)
sqrt(x) square root of x
tan(x) trigonometric tangent of x (x in radians).

The Math object also defines mathematical constants.
By convention all constants are written in all uppercase letters.

Constant Value
Math.E Euler’s constant
Math.LN2 Natural logarithm of 2
Math.LN10 Natural logarithm of 10
Math.LOG2E Base 2 of logarithm of Euler’s constant
Math.LOG10E Base 10 of logarithm of Euler’s constant
Math.PI PI – the ratio of a circle’s circumference to its diameter.
Math.SQRT1_2 Square root of 0.5
Math.SQRT2 Square root of 2.0

Welcome to Kaizenlog.com If you're new here, you may want to subscribe to my RSS feed , Twitter You can contact us by using the contact form or submitting a comment. You can also share this post with your friends by clicking on the 'ShareThis' button above. Thanks for visiting!



Print This Post Print This Post





  • Related Posts



  • Leave a Reply