KandZ – Tuts

We like to help…!

JavaScript 25 🧬 Math Object

a - Info about Math object and its constants
The Math object in JavaScript is a versatile tool for performing a wide range of mathematical operations.
the Math object provides everything you need to handle most mathematical tasks in JavaScript.
From basic arithmetic and rounding to more advanced functions like trigonometry and random number generation
Constants:
E β†’ Euler's number (approximately 2.718)
PI β†’ Pi, the ratio of a circle’s circumference to its diameter (approximately 3.14159)
SQRT2 β†’ Square root of 2, approximately 1.414
LN2 β†’ Natural logarithm of 2, approximately 0.693
LN10 β†’ Natural logarithm of 10, approximately 2.303

b - Math object methods Part 1
Rounding Methods
Math.round() β†’ Rounds a number to the nearest integer.
Math.ceil() β†’ Rounds a number up to the nearest integer.
Math.floor(): β†’ Rounds a number down to the nearest integer.
Exponential and Logarithmic Functions
Math.exp() β†’ Returns the value of E raised to a given power.
Math.pow(base, exponent) β†’ Returns the base raised to the exponent power.
Math.log() β†’ Returns the natural logarithm (base E) of a number.
Other Basic Math Functions
Math.abs(): Returns the absolute value of a number.
Math.sign(): Returns the sign of a number. It can return -1, 0, or 1.

c - Math object methods Part 2
Trigonometric Functions
Math.sin(), Math.cos(), Math.tan() β†’ These functions return the sine, cosine, and tangent of a given angle in radians.
Math.asin(), Math.acos(), Math.atan() β†’ These functions return the arcsine, arccosine, and arctangent of a number.
Common Miscellaneous Methods
Math.max() β†’ Returns the largest of zero or more numbers.
Math.min() β†’ Returns the smallest of zero or more numbers.
Math.random() β†’ Generates a random floating-point number between 0 (inclusive) and 1 (exclusive).

Leave a Reply