JavaScript Math Object Methods

In JavaScript, the Math object contains various methods and constants which are used for mathematical operations.

JavaScript Math Object Methods: This section contains various Math object methods and constants with examples.

List of JavaScript Math Object Constants & Methods

Constant & Method Description
Math.LN2 It returns the value of natural log 2.
Math.LN10 It returns the value of natural log 10.
Math.PI It returns the value of PI constant.
Math.SQRT1_2 It returns the value of square root of ½.
Math.SQRT2 It returns the value of square root of 2.
Math.LOG10E It returns the value of base 10 logarithm of E.
Math.abs() It returns the absolute value of the given number.
Math.pow() It returns the value of x to the power of y, where x is the first parameter and y is the second parameter.
Math.sqrt() It returns the square root of the given number.
Math.cbrt() It returns the cube root of the given number.
Math.round() It returns the rounded value (nearest to given integer) of the given number.
Math.min() It returns the smallest value from the given values.
Math.max() It returns the largest value from the given values.
Math.sign() It returns the sign of the given value.
Math.trunc() It returns the integer part of the given value.
Math.log() It returns the natural logarithm of given value.
Math.log2() It returns the base-2 logarithm of given value.
Math.log10() It returns the base-10 logarithm of given value.
Math.exp() It returns the value of Ex.
Math.expm1() It returns the value of EP-1.
Math.random() It returns the random number between 0 to 1.
Math.sin() It returns the sine value of the given number.
Math.asin() It returns the arcsine value of the given number.
Math.sinh() It returns the hyperbolic sine of the given number.
Math.asinh() It returns the hyperbolic arcsine of the given number.
Math.cos() It returns the cosine value of the given number.
Math.acos() It returns the arccosine value of the given number.
Math.cosh() It returns the hyperbolic cosine value of the given number.
Math.acosh() It returns the hyperbolic arccosine value of the given number.
Math.tan() It returns the tangent of an angle.
Math.tanh() It returns the hyperbolic tangent of an angle.
Math.atan() It returns the arctangent of an angle.
Math.atan2() It returns the arctangent of the quotient of its given parameters.
Math.atanh() It returns the hyperbolic arctangent of an angle.
Math.ceil() It returns the given number, rounded upwards to the nearest integer.
Math.floor() It returns the given number, rounded downwards to the nearest integer.
Math.clz32() It returns the number of leading zeros in a 32-bit binary representation of the given number.
Math.imul() It returns the 32-bit multiplication of the given values.


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.