JavaScript math methods

JavaScript comprehensive list of all JavaScript Math methods

{type} method
{parameter} {Number}
{description} It returns a given number rounded off to the nearest integer.
ie Math.round(0.6251) // returns 1
or Math.round(1.7252) // returns 2

{type} method
{parameter} {Number}, {Number}
{description} It returns a given number raised to the power the exponent.
ie Math.pow(2, 5) // returns 32
or Math.pow(7, 2) // returns 49

{type} method
{parameter} {Number}
{description} It returns the square root of a given integer.
ie Math.sqrt(25) // returns 5
or Math.sqrt(64) // returns 8

{type} method
{parameter} {Number}
{description} It returns absolute positive value of a given number
ie Math.abs(-10) // returns 10
or Math.abs(52) // returns 52

{type} method
{parameter} {Number}
{description} It returns a smaller number which is greater or equal to the given integer.
ie Math.ceil(9.87) // returns 10
or Math.ceil(51.5) // returns 52

{type} method
{parameter} {Number}
{description} It returns a more larger number, lesser or equal to the given integer
ie Math.floor(9.35) // returns 9
or Math.floor(51.25) // returns 51

{type} method
{parameter} {Number}
{description} It returns sine of a given number.
ie Math.sin(360) // returns 0
or Math.sin(180) // returns 0

{type} method
{parameter} {Number}
{description} It returns cosine of a given number.
ie Math.cos(360) // returns 1
or Math.cos(180) // returns -1

{type} method
{parameter} {Number}
{description} It returns smallest number among given numbers.
ie Math.min(...[9, 8]) // returns 8
or Math.min(...[8, 5]) // returns 5

{type} method
{parameter} {Number}
{description} It returns biggest number among given numbers.
ie Math.min(...[9, 8]) // returns 9
or Math.min(...[8, 5]) // returns 8

{type} method
{parameter} {Number}
{description} It returns a random number between 0 and 1 the number can't be zero or one it's normally a decimal
ie Math.random() // returns 0.32...
or Math.random() // returns 0.51...

{type} method
{parameter} {Number}
{description} It retuns arccosine of a given integer.
ie Math.arccos() // returns ....
or Math.arccos() // returns ...

{type} method
{parameter} {Number}
{description} It retuns arcsine of a given integer
ie Math.arcsine() // returns ....
or Math.arcsine() // returns ...


Popular posts from this blog

How to set content disposition header for nginx server to force content download

Animated daylight on HTML5 Canvas

How to make a static http server in nodejs using express

How to make a Snake Game using JavaScript and html5

JS13K Preparation