Quick Reference
This is a quick reference list of JavaScript math methods and properties with examples of how they are used.
- JavaScript – Math.abs() MethodThe Math.abs() method returns the absolute value of a number.
- JavaScript – Math.acos() MethodThe 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() MethodThe 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() MethodThe 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() MethodThe Math.asinh() method returns the hyperbolic arcsine of a number.
- JavaScript – Math.atan() MethodThe Math.atan() method returns the arctangent of a number as a value between -PI/2 and PI/2 radians.
- JavaScript – Math.atan2() MethodThe Math.atan2() method returns the arctangent of the quotient of its arguments, as a numeric value between PI and -PI radians.
- JavaScript – Math.atanh() MethodThe 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() MethodThe Math.cbrt() method returns the cubic root of a number.
- JavaScript – Math.ceil() MethodThe Math.ceil() method returns a number rounded up to the nearest integer.
- JavaScript – Math.clz32() MethodThe Math.clz32() method returns the number of leading zeros in a 32-bit binary number.
- JavaScript – Math.cos() MethodThe Math.cos() method returns the cosine of a number (entered in radians). The returned number will be between -1 and 1.
- JavaScript – Math.cosh() MethodThe Math.cosh() method returns the hyperbolic cosine of a number.
- JavaScript – Math.E PropertyThe Math.E property returns Euler’s number, which is approximately 2.71828.
- JavaScript – Math.exp() MethodThe 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() MethodThe 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() MethodThe Math.floor() method returns a number rounded down to the nearest integer.
- JavaScript – Math.fround() MethodThe Math.fround() method returns the nearest 32-bit single-precision-float representation of a number.
- JavaScript – Math.LN2 PropertyThe Math.LN2 property returns the natural logarithm of 2, which is approximately 0.693.
- JavaScript – Math.LN10 PropertyThe Math.LN10 property returns the natural logarithm of 10, which is approximately 2.3025.
- JavaScript – Math.log() MethodThe Math.log() method returns the natural logarithm (base E) of a number.
- JavaScript – Math.log10() MethodThe Math.log10() method returns the base-10 logarithm of a number.
- JavaScript – Math.LOG10E PropertyThe Math.LOG10E property returns the base-10 logarithm of E (Euler’s Number), which is approximately 0.434.
- JavaScript – Math.log1p() MethodThe Math.log1p() method returns the natural logarithm (base E) of 1 + a number.
- JavaScript – Math.log2() MethodThe Math.log2() method returns the base-2 logarithm of a number.
- JavaScript – Math.LOG2E PropertyThe Math.LOG2E property returns the base-2 logarithm of E (Euler’s Number), which is approximately 1.442.
- JavaScript – Math.max() MethodThe Math.max() method returns the number with the highest value from one or more numbers.
- JavaScript – Math.min() MethodThe Math.min() method returns the number with the lowest value from one or more numbers.
- JavaScript – Math.PI PropertyThe Math.PI property returns PI (the ratio of a circle’s area to the square of its radius, approximately 3.14).
- JavaScript – Math.pow() MethodThe Math.pow() method returns the value of x to the power of y (e.g., xy).
- JavaScript – Math.random() MethodThe Math.random() method returns a random number from 0 (inclusive) up to but not including 1 (exclusive).
- JavaScript – Math.round() MethodThe 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() MethodThe Math.sign() method returns whether a number is negative, positive or zero.
- JavaScript – Math.sin() MethodThe Math.sin() method returns the sine of a number (entered in radians). The returned number will be between -1 and 1.
- JavaScript – Math.sinh() MethodThe Math.sinh() method returns the hyperbolic sine of a number.
- JavaScript – Math.sqrt() MethodThe Math.sqrt() method returns the square root of a number.
- JavaScript – Math.SQRT1_2 PropertyThe Math.SQRT1_2 property returns the square root of 1/2, which is approximately 0.707.
- JavaScript – Math.SQRT2 PropertyThe Math.SQRT2 property returns the square root of 2, which is approximately 1.414.
- JavaScript – Math.tan() MethodThe Math.tan() method returns the tangent of a number.
- JavaScript – Math.tanh() MethodThe Math.tanh() method returns the hyperbolic tangent of a number.
- JavaScript – Math.trunc() MethodThe Math.trunc() method returns the integer part of a number by removing everything after the decimal point. It does not round the number.
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)
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.