0% found this document useful (0 votes)
19 views1 page

Js Math Methods Cheat Sheet

Uploaded by

LifeLine5i
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views1 page

Js Math Methods Cheat Sheet

Uploaded by

LifeLine5i
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

JavaScript String Methods Cheat Sheet

Method Description Example Output


Math.abs(x) Returns absolute value Math.abs(-5) 5
Math.ceil(x) Rounds up Math.ceil(4.2) 5
Math.floor(x) Rounds down Math.floor(4.9) 4
Math.round(x) Rounds to nearest integer Math.round(4.6) 5
Math.trunc(x) Removes decimal part Math.trunc(4.9) 4
Math.max(a, b, ...) Returns largest number Math.max(3, 7, 2) 7
Math.min(a, b, ...) Returns smallest number Math.min(3, 7, 2) 2
Math.pow(x, y) Returns x to the power y Math.pow(2, 3) 8
Math.sqrt(x) Returns square root Math.sqrt(16) 4
Math.cbrt(x) Returns cube root Math.cbrt(27) 3
Math.random() Random number [0,1) Math.random() ~0.123
Math.floor(Math.random()*n)
Random integer [0,n) Math.floor(Math.random()*10) 0 to 9
Math.log(x) Natural logarithm Math.log(Math.E) 1
Math.log10(x) Base-10 logarithm Math.log10(100) 2
Math.sin(x) Sine (radians) Math.sin(Math.PI/2) 1
Math.cos(x) Cosine (radians) Math.cos(0) 1
Math.tan(x) Tangent (radians) Math.tan(Math.PI/4) 1
Math.sign(x) Sign of number Math.sign(-3) -1
Math.E Euler's number Math.E 2.718...
Math.PI Pi value Math.PI 3.1416...

Page 1

You might also like