# 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 E^{x}, 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, base^{exponent}. |
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

**Object.freeze**

const box = { p: 10, q: 20 }; Object.freeze(box); const shape = box; shape.p = 100; console.log(shape);

Object.freeze makes it impossible to add, remove, or modify properties of an object (unless the property's value is another object).

When we create the variable shape and set it equal to the frozen object box, shape also refers to a frozen object. You can check whether an object is frozen by using Object.isFrozen. In this case, Object.isFrozen(shape) returns true, since the variable shape has a reference to a frozen object.

Since shape is frozen, and since the value of p is not an object, we cannot modify the property p. p is still equal to 10, and { p: 10, q: 20 } gets logged.

Ref: https://bit.ly/3jFRBje

**Weekly Trends**- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join

We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook