The JavaScript Math object gives you powerful routines that let you generate random numbers, convert numbers to strings and strings to numbers, and perform trigonometric functions and much more. After this introduction, you should be able to create some interesting JavaScript applications.
Welcome to Bucaro TecHelp!

Welcome to Bucaro TecHelp!
Maintain Your Computer and Use it More Effectively
to Design a Web Site and Make Money on the Web

[About BTH]  [User Agreement]  [Privacy Policy]  [Site Map]  [Contact Form]  [Advertise on BTH]  [News Feed]

Google
Web
This Site

Win $3,500.00 worth of gas!

JavaScript Math Object

The JavaScript Math object gives you powerful routines that let you find Square root, logarithms, raise a number to a power, perform trigonometric functions and much more. In addition it provides several properties, such as the value of natural logarithm e, and the value of pi.

Math Object Properties

Property Value Description
Math.E 2.718281828459045091 Natural log
Math.LN2 0.6931471805599452862 Natural log of 2
Math.LN10 2.302585092994045901 Natural log of 10
Math.LOG2E 1.442695040888963387 Base-2 log of e
Math.LOG10E 0.4342944819032518167 base-10 Log of e
Math.PI 3.141592653589793116 pi

Because these properties return their values, you can use them like constants in your mathematical expressions. For example, to obtain the circumference of a circle whose diameter is d, use the statement below:

circumference = d * Math.PI

Math Object Methods

Method Returns
Math.abs(value) Absolute value
Math.acos(value) Arc cosine in radians
Math.asin(value) Arc sine in radians
Math.atan(value) Arc tangent in radians
Math.atan2(value1, value2)Angle of polar coordinates x and y
Math.ceil(value) Next integer greater than or equal to value
Math.cos(value) Cosine
Math.exp(value) Raise log e to the power of value
Math.floor(value) Next integer less than or equal to value
Math.log(value) Natural logarithm (base e)
Math.max(value1, value2)The greater of value1 or value2
Math.min(vallue1, value2)The lesser of value1 or value2
Math.pow(vallue1, value2)Value1 to the value2 power
Math.random() Random number between 0 and 1
Math.round(value) value + 1 when value >= value.5 otherwise value
Math.sin(value) Sine in radians
Math.sqrt(value) Square root
Math.tan(value) Tangent

Most Math object methods take one or two values as parameters, the only Math object method that doesn't take a value as a parameter is the random method.

Web Design Sections

RSS Feed RSS Feed

Java Script Quick Reference
Java Script Data Types
Java Script Reserved Words
Java Script Arithmetic Operators
Comparison Operators
Java Script Arrays
Java Script Character Encoding and Decoding
The if/else Structure
The switch/case Structure
The for Loop
The while Loop
The break Statement
The continue Statement
JavaScript Math Object
Round a Number
Determine Absolute Value
Determine Minimum and Maximum
Generating Random Numbers
Java Script Trigonometric Methods
Java Script Number Object
Format a Number as Currency
Java Script Strings
Compare Two Strings
Find a Character or a Substring Within a String
Include a Quote Character in a String
Include a Backslash Character in a String
Define Lines in a String
Use Escape to Replace Dangerous Characters
Convert a Number to a String
Convert a String to a Number
The Document Object Model (DOM)
Accessing Web Page Elements
Interactively Set Webpage Colors
Get Webpage File Date and File Size
Dueling Windows
Cookie Power Made Easy

Get paid cash typically $4 to $25 for each survey you complete!

[Site User Agreement]  [Advertise on This site]  [Search This Site]  [Contact Form]
Copyright©2001-2007 Bucaro TecHelp P.O.Box 18952 Fountain Hills, AZ 85269