- Tags: Math
- Categories: JavaScript Reference, JavaScript Resources, Reference
Quick Reference
This is a quick reference list of JavaScript math methods and properties with examples of how they are used.
JavaScript – Math.abs() Method
The Math.abs() method returns the absolute value of a number.
JavaScript – Math.acos() Method
The Math.acos() method returns the arccosine (in radians) of a number. The Math.acos() method expects a parameter in the range -1 to 1.
JavaScript – Math.acosh() Method
The Math.acosh() method returns the hyperbolic arccosine of a number. If the parameter is less than 1 or not a number, the method returns NaN.
JavaScript – Math.asin() Method
The Math.asin() method returns the arcsine (in radians) of a number. The Math.asin() method expects a parameter in the range -1 to 1.
JavaScript – Math.asinh() Method
The Math.asinh() method returns the hyperbolic arcsine of a number.
JavaScript – Math.atan() Method
The Math.atan() method returns the arctangent of a number as a value between -PI/2 and PI/2 radians.
JavaScript – Math.atan2() Method
The Math.atan2() method returns the arctangent of the quotient of its arguments, as a numeric value between PI and -PI radians.
JavaScript – Math.atanh() Method
The Math.atanh() method returns the hyperbolic arctangent of a number. The Math.atanh() method expects a parameter in the range -1 to 1.
JavaScript – Math.cbrt() Method
The Math.cbrt() method returns the cubic root of a number.
JavaScript – Math.ceil() Method
The Math.ceil() method returns a number rounded up to the nearest integer.
JavaScript – Math.clz32() Method
The Math.clz32() method returns the number of leading zeros in a 32-bit binary number.
JavaScript – Math.cos() Method
The Math.cos() method returns the cosine of a number (entered in radians). The returned number will be between -1 and 1.
JavaScript – Math.cosh() Method
The Math.cosh() method returns the hyperbolic cosine of a number.
JavaScript – Math.E Property
The Math.E property returns Euler’s number, which is approximately 2.71828.
JavaScript – Math.exp() Method
The Math.exp() method returns the value of E squared, where E is Euler’s number and x is the parameter passed to it.
JavaScript – Math.expm1() Method
The Math.exp() method returns the value of E squared minus 1, where E is Euler’s number and x is the parameter passed to it.
JavaScript – Math.floor() Method
The Math.floor() method returns a number rounded down to the nearest integer.
JavaScript – Math.fround() Method
The Math.fround() method returns the nearest 32-bit single-precision-float representation of a number.
JavaScript – Math.LN2 Property
The Math.LN2 property returns the natural logarithm of 2, which is approximately 0.693.
JavaScript – Math.LN10 Property
The Math.LN10 property returns the natural logarithm of 10, which is approximately 2.3025.
JavaScript – Math.log() Method
The Math.log() method returns the natural logarithm (base E) of a number.
JavaScript – Math.log10() Method
The Math.log10() method returns the base-10 logarithm of a number.
JavaScript – Math.LOG10E Property
The Math.LOG10E property returns the base-10 logarithm of E (Euler’s Number), which is approximately 0.434.
JavaScript – Math.log1p() Method
The Math.log1p() method returns the natural logarithm (base E) of 1 + a number.
JavaScript – Math.log2() Method
The Math.log2() method returns the base-2 logarithm of a number.
JavaScript – Math.LOG2E Property
The Math.LOG2E property returns the base-2 logarithm of E (Euler’s Number), which is approximately 1.442.
JavaScript – Math.max() Method
The Math.max() method returns the number with the highest value from one or more numbers.
JavaScript – Math.min() Method
The Math.min() method returns the number with the lowest value from one or more numbers.
JavaScript – Math.PI Property
The Math.PI property returns PI (the ratio of a circle’s area to the square of its radius, approximately 3.14).
JavaScript – Math.pow() Method
The Math.pow() method returns the value of x to the power of y (e.g., xy).
JavaScript – Math.random() Method
The Math.random() method returns a random number from 0 (inclusive) up to but not including 1 (exclusive).
JavaScript – Math.round() Method
The Math.round() method rounds a number to the nearest integer. For example, 1.49 will be rounded down to 1, while 1.5 will be rounded up to 2.
JavaScript – Math.sign() Method
The Math.sign() method returns whether a number is negative, positive or zero.
JavaScript – Math.sin() Method
The Math.sin() method returns the sine of a number (entered in radians). The returned number will be between -1 and 1.
JavaScript – Math.sinh() Method
The Math.sinh() method returns the hyperbolic sine of a number.
JavaScript – Math.sqrt() Method
The Math.sqrt() method returns the square root of a number.
JavaScript – Math.SQRT1_2 Property
The Math.SQRT1_2 property returns the square root of 1/2, which is approximately 0.707.
JavaScript – Math.SQRT2 Property
The Math.SQRT2 property returns the square root of 2, which is approximately 1.414.
JavaScript – Math.tan() Method
The Math.tan() method returns the tangent of a number.
JavaScript – Math.tanh() Method
The Math.tanh() method returns the hyperbolic tangent of a number.
JavaScript – Math.trunc() Method
The Math.trunc() method returns the integer part of a number by removing everything after the decimal point. It does not round the number.
We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.
Why 1SMARTchicken?
See More →
Thanks for your support!
JavaScript Books
All are affiliate links. Thank you for your support!
JAVASCRIPT NOTES:
- When using JavaScript, single or double quotation marks are acceptable and work identically to one another; choose whichever you prefer, and stay consistent
- JavaScript is a case-sensitive language; firstName is NOT the same as firstname
- Arrays count starting from zero NOT one; so item 1 is position [0], item 2 is position [1], and item 3 is position [2] … and so on
- JavaScript variables must begin with a letter, $, or _
- JavaScript variables are case sensitive (x is not the same as X)
Feedback
If you see an error on the page or the code itself is incorrect or incomplete, or just plain wrong, please let us know. We’re always learning. NOTE: we do not sell your information and will not send you spam emails.