JavaScript Tutorial





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
Java-Script Tutorial
Introduction Introduction
Variables Variables
Operators Operators
Statements Statements
Loops Loops
Functions Functions
Objects Objects
Arrays Arrays
Cookies JS Cookies
Browser Objects Browser Objects
Form DOM Form DOM
Style Objects DOM Style Objects
Forums Ask Your Doubts
Scraps More about Javascript
Feedback Feedback
 




Math Methods or Function


Tutorials »Javascript »

Topic

how to do math calculations in javascript?
or
what are the methods to do mathematical operations in javascript?



Explanation

Object: Math

      Math object contains the methods or function that can be used to easily do mathematical calculations. Math object is an in built object and so it is not required to instantiate the object as done for Date object. Math also contains pre-defined variables that will give values of important constants like Pi, LN2, log base 10 etc...

To use math object:
Syntax: Math.methodName()

Explanation:
To call a math method, just use the name Math followed by its method name, separated by a dot.

Example: Math.random()
This method call generates a random number.

Math object can be categorized as

Basic Math Functions Trigonometric Functions Math Variables or Constants




A Note
Javascript (JS) is one of the most used languages in the world. Some times spelled as Java Script. Hope you enjoy this tutorial. Do send your feedback or suggestions on this javascript or java script tutorial. This is a copyright content.

Other Links

web hosting