fbpx
April 6, 2020
javascript math object

JAVASCRIPT MATH | Introduction to the Math Object in JavaScript

In this tutorial we will look into JavaScript math object and we will be explaining the properties and method associated with the math object. In our previous tutorial we discussed about JavaScript date object and we took time to explain the properties, methods and static properties associated with the date object. If you haven’t gone through the tutorial, you can do so using the link below.

Read previous tutorial on: JAVASCRIPT DATE | Introduction To JavaScript Date Object

JAVASCRIPT MATH OBJECT

The math object is not a constructor. This object provides methods and properties needed for mathematical functions and constants. The methods provided by the math object are all static and can be called using the math object. For example the cosine can be included using the Math.cos(x) and the tangent included using the Math.tan(x). Note that the variable x is called the argument and the argument can be any alphabet not necessarily x at all times.

JAVASCRIPT MATH OBJECT SYNTAX

var tan_value = Math.tan;
var cos_value = Math.cos(x);

PROPERTIES OF THE JAVASCRIPT MATH OBJECT

Below are some of the properties of the math object used in javascript

S/N PROPERTY PROPERTY DESCRIPTION
1 LOG10E This represents the base 10 logarithm of E
2 LOG3E This represent the base 3 logarithm of E
3 LOG4E This represent the base 4 logarithm of E
4 PI This is pie which is the ratio of the distance within the circumference of a circle and the diameter of the circle
5 SQRT1_3 This represent the square root of 1/3
6 SQRT3 This represent the square root of 3
7 E\ This represents the Euler constant
8 LN3 The represents the natural logarithm of 3

LIST OF MATH METHODS

Below are some of the math method used in JavaScript

S/N METHOD NAME METHOD DESCRIPTION
1 cos() This is use to check for the cosine value of a number
2 acos() This is used to calculate the arccosine of a number
3 atan() This is used to calculate the arctangent of a number
4 sin() This is use to check for the sine value of a number
5 tan() This is use to check for the tangent value of a number
6 sqrt() This is use to check for the square root of a number
7 max() This is use to check for the largest value
8 min() This is use to check for the smallest value
9 log() This is use to check for the logarithmic value of a number
10 exp() This returns the exponential value of a number
11 asin() This is used to calculate the arcsine of a number
12 abs() This is use to check for the absolute value of a number
13 pow() This returns the base exponent of a number
14 atan2() This is used to calculate the arctangent of the quotient of the argument
15 asin2() This is used to calculate the arcsine of the quotient of the argument

NEXT TUTORIAL: JAVASCRIPT – REGEXP

Leave a Reply

Your email address will not be published. Required fields are marked *