JavaScript math methods

JavaScript comprehensive list of all JavaScript Math methods

Math.round()
{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

Math.pow()
{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

Math.sqrt()
{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

Math.abs()
{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

Math.ceil()
{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

Math.floor()
{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

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

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

Math.min()
{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

Math.max()
{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

Math.random()
{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...

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

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

Comments

Popular posts from this blog

How to get user's ip address in JavaScript

How to make a static http server in nodejs using express

Array concat method in JavaScript

What is 'this.' keyword in JavaScript

How to create promises in JavaScript