Javascript Math Objects - Properties and Methods
Description
JavaScript math object is a top-level, a predefined object for mathematical constants and functions.
Can not be created by the user. It is a predefined object
Mathematical properties and functions can be calculated by math.property or math.method (for example math.abs(4.568)).
Javascript Math Objects Property
Name | Description | Version |
---|---|---|
E | Returns the mathematical constant E, the base of natural logarithms, approximately 2.718. | Implemented in JavaScript 1.2 |
LN10 | Returns the natural logarithm of 10, approximately 2.302. | Implemented in JavaScript 1.2 |
LN2 | Returns the natural logarithm of 2, approximately 0.693. | Implemented in JavaScript 1.2 |
LOG10E | Returns the base 10 logarithm of E (approximately equal to 0.434). | Implemented in JavaScript 1.2 |
LOG2E | Returns the base 2 logarithm of E (approximately equal to 1.442). | Implemented in JavaScript 1.2 |
PI | Returns the ratio of the circumference of a circle to its diameter ( approximately 3.14159). | Implemented in JavaScript 1.2 |
SQRT1_2 | Returns the square root of 1/2 i.e. 0.5, approximately 0.707. | Implemented in JavaScript 1.2 |
SQRT2 | Returns the square root of 2 (approximately 1.414). | Implemented in JavaScript 1.2 |
Javascript Math Objects Methods
Name | Description | Version |
---|---|---|
abs | Use to get the absolute value of a number. | Implemented in JavaScript 1.2 |
acos | Use to get the arccosine (in radians) of a number. | Implemented in JavaScript 1.2 |
asin | Use to get the arcsine (in radians) of a number. | Implemented in JavaScript 1.2 |
atan | Use to get the arctangent (in radians) of a number. | Implemented in JavaScript 1.2 |
atan2 | Use to get the arctangent of the quotient of its arguments. | Implemented in JavaScript 1.2 |
ceil | Use to get the smallest integer, greater than or equal to a number. | Implemented in JavaScript 1.2 |
cos | Use to get the the cosine of a number. | Implemented in JavaScript 1.2 |
exp | Returns Ex, where x is the argument, and E is Euler's constant, the base of the natural logarithms. | Implemented in JavaScript 1.2 |
floor | Use to get the largest integer, less than or equal to a number. | Implemented in JavaScript 1.2 |
log | Use to get the natural logarithm (base E) of a number. | Implemented in JavaScript 1.2 |
max | Use to get the larger of two given numbers. | Implemented in JavaScript 1.2 |
min | Use to get the smaller of two given numbers. | Implemented in JavaScript 1.2 |
pow | Returns base to the exponent power, that is, baseexponent. | Implemented in JavaScript 1.2 |
random | Use to get the pseudo-random number between 0 and 1. | Implemented in JavaScript 1.2 |
round | Use to get the value of a number rounded to the nearest integer. | Implemented in JavaScript 1.2 |
sin | Use to get the sine of a number. The sin method returns a numeric value between -1 and 1 | Implemented in JavaScript 1.2 |
sqrt | Use to get the square root of a number. | Implemented in JavaScript 1.2 |
tan | Use to get the tangent of a number. | Implemented in JavaScript 1.2 |
See also:
Test your Programming skills with w3resource's quiz.
JavaScript: Tips of the Day
How to insert an item into an array at a specific index (JavaScript)?
What you want is the splice function on the native array object.
arr.splice(index, 0, item); will insert item into arr at the specified index (deleting 0 items first, that is, it's just an insert). In this example we will create an array and add an element to it into index 2:
var arr = []; arr[0] = "Jani"; arr[1] = "Hege"; arr[2] = "Stale"; arr[3] = "Kai Jim"; arr[4] = "Borge"; console.log(arr.join()); arr.splice(2, 0, "Lene"); console.log(arr.join());
Ref: https://bit.ly/2BXbp04
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework