js study concluded (4)

This part describes common methods of the Math object

 

1.Math.abs (value), the value is converted to absolute values. such as:

console.log(Math.abs(-567));

Print the return value is 567

 

2.Math.ceil (value), the values ​​are rounded up. such as:

console.log(Math.ceil(5.666));

Print the return value of 6

 

3.Math.floor (value), the value is rounded down. such as:

console.log(Math.ceil(5.666));

Print return value 5

 

4.Math.random (), randomly generated within a decimal range of 0-1. such as:

console.log(Math.random());

Returns the print range is a random decimal 0-1, such 0.6973378142792437

 

5.Math.round (value), the value is rounded to the nearest integer. such as:

console.log(Math.round(5.666));

Print the return value of 6

Guess you like

Origin www.cnblogs.com/woywan/p/12651989.html