- Javascript - Page Printing
- Javascript - Void Keyword
- Javascript - Dialog Boxes
- Javascript - Page Redirect
- Javascript - Cookies
- Javascript - Events
- Javascript - Functions
- Javascript - Loop Control
- Javascript - For...in
- Javascript - For Loop
- Javascript - While Loop
- Javascript - Switch Case
- Javascript - If...Else
- Javascript - Operators
- Javascript - Variables
- Javascript - Placement
- Javascript - Enabling
- Javascript - Syntax
- Javascript - Overview
- Javascript - Home
JavaScript Objects
- Javascript - HTML DOM
- Javascript - RegExp
- Javascript - Math
- Javascript - Date
- Javascript - Arrays
- Javascript - Strings
- Javascript - Boolean
- Javascript - Number
- Javascript - Objects
JavaScript Advanced
- Javascript - Browsers
- Javascript - Image Map
- Javascript - Debugging
- Javascript - Multimedia
- Javascript - Animation
- Javascript - Validations
- Javascript - Error Handling
JavaScript Useful Resources
- Javascript - Resources
- Javascript - Functions
- Javascript - Quick Guide
- Javascript - Questions And Answers
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
JavaScript - The Math Object
The math object provides you properties and methods for mathematical constants and functions. Unpke other global objects, Math is not a constructor. All the properties and methods of Math are static and can be called by using Math as an object without creating it.
Thus, you refer to the constant pi as Math.PI and you call the sine function as Math.sin(x), where x is the method s argument.
Syntax
The syntax to call the properties and methods of Math are as follows
var pi_val = Math.PI; var sine_val = Math.sin(30);
Math Properties
Here is a pst of all the properties of Math and their description.
Sr.No. | Property & Description |
---|---|
1 | Euler s constant and the base of natural logarithms, approximately 2.718. |
2 | Natural logarithm of 2, approximately 0.693. |
3 | Natural logarithm of 10, approximately 2.302. |
4 | Base 2 logarithm of E, approximately 1.442. |
5 | Base 10 logarithm of E, approximately 0.434. |
6 | Ratio of the circumference of a circle to its diameter, approximately 3.14159. |
7 | Square root of 1/2; equivalently, 1 over the square root of 2, approximately 0.707. |
8 | Square root of 2, approximately 1.414. |
In the following sections, we will have a few examples to demonstrate the usage of Math properties.
Math Methods
Here is a pst of the methods associated with Math object and their description
Sr.No. | Method & Description |
---|---|
1 | Returns the absolute value of a number. |
2 | Returns the arccosine (in radians) of a number. |
3 | Returns the arcsine (in radians) of a number. |
4 | Returns the arctangent (in radians) of a number. |
5 | Returns the arctangent of the quotient of its arguments. |
6 | Returns the smallest integer greater than or equal to a number. |
7 | Returns the cosine of a number. |
8 | Returns EN, where N is the argument, and E is Euler s constant, the base of the natural logarithm. |
9 | Returns the largest integer less than or equal to a number. |
10 | Returns the natural logarithm (base E) of a number. |
11 | Returns the largest of zero or more numbers. |
12 | Returns the smallest of zero or more numbers. |
13 | Returns base to the exponent power, that is, base exponent. |
14 | Returns a pseudo-random number between 0 and 1. |
15 | Returns the value of a number rounded to the nearest integer. |
16 | Returns the sine of a number. |
17 | Returns the square root of a number. |
18 | Returns the tangent of a number. |
19 | Returns the string "Math". |
In the following sections, we will have a few examples to demonstrate the usage of the methods associated with Math.
Advertisements