Table of Contents
This guide covers math object in JavaScript with practical context and easy-to-follow details. Use it to understand the subject and apply the information confidently.
So, you refer to the constant pi as Math. PI And you call the Sine Function as Math. Sin (x) , where x is the parameter of the method.
Syntax
The syntax for calling properties and methods of Math is as follows:
var pi_val = Math . PI ; var sine_val = Math . sin ( 30 );
Math Properties
The table below lists the properties of Math and describes it.
Attribute DescriptionE The E constant, and the base of the natural algorithm (symbol: ln), approximately 2. 718 LN2 Natural logarithm of 2, approximately 0. 693. LN10 Natural logarithm of 10, approximately 2, 302. LOG2E Base 2 Logarithm of E, approximately 1, 442. LOG10E Logarithm base 10 of E, approximately 0. 434. PI Pi coefficient, approximately 3. 14159. SQRT1_2 The square root of 1/2; approximately 0. 707. SQRT2 The square root of 2, approximately 1, 414.
Math Methods
The table below lists Math's methods and describes it.
Method Descriptionabs () Returns the absolute value of some acos () Returns arccos (radians value) of some asin () Returns arcsin (radians value) of some atan () Returns arctan (value radians) of some atan2 () Returns inverse trigonometric tang ceil () Returns the smallest integer number greater than or equal to a number cos () Returns cos of a number. Exp () Returns E, where N is the parameter, and E is the Euler floor constant () Returns the largest integer smaller than or equal to a log number () Returns the base e-logarithm of a maximum number () Returns the maximum number of 0 or more min () Returns the smallest number of 0 or more pow numbers () Returns the value of (base)(exponent). Random () Returns a random number between two numbers 0 and 1. Round () Rounds the number. Returns the value of the nearest integer. Sin () Returns the sine of some sqrt () Returns the square root of some tan () Returns the tan of some toSource () Returns the "Math" string
According to Tutorialspoint
Previous article: Date object in JavaScript
Next lesson: Regular Expression and RegExp in JavaScript
FAQ
What should I check before following these steps?
Confirm device and software compatibility, save important data, and make sure you have the required permissions, files, and account access.
Why might the process not work?
Common causes include outdated software, missing permissions, incompatible hardware, an unstable connection, or completing a step in the wrong order.
Can I undo the changes if necessary?
That depends on the tool or setting. Use built-in restore options when available, keep a backup, and record the original configuration first.
Reader Comments 0
Sign in with email or Google to join the discussion.