How to understand JavaScript math
How to understand JavaScript math, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.
JavaScript's Math object allows you to perform mathematical operations on numbers.
1. Mathematical function
1. Basic function
1.Math.PI
Project JavaScript Math.PI
Math.PI returns the ratio of the circumference to its diameter:
Document.getElementById ("demo") [xss_clean] = Math.PI
2. Math.round ()
Math.round (x) returns the value of x rounded to its nearest integer.
Project JavaScript Math.round ()
Math.round (x) returns the value of x rounded to its nearest integer:
Document.getElementById ("demo") [xss_clean] = Math.round (4.4)
3. Math.pow ()
Math.pow (x, y) x to the y power.
Document.getElementById ("demo") [xss_clean] = Math.pow (8. 2); / / returns 64
4. Math.sqrt ()
The square root of Math.sqrt (x) x.
Document.getElementById ("demo") [xss_clean] = Math.sqrt (64); / / returns 8
5. Math.abs ()
The absolute value of Math.abs (x) x.
Document.getElementById ("demo") [xss_clean] = Math.Math.abs (- 4.7); / / returns 4.7
6. Math.ceil ()
Math.ceil (x) returns the value of x rounded up to its nearest integer.
Document.getElementById ("demo") [xss_clean] = Math.ceil (4.4); / / returns 5
7. Math.floor ()
Math.floor (x) returns the value of x rounded down to its nearest integer.
Document.getElementById ("demo") [xss_clean] = Math.floor (4.7); / / does returns 4 help you after reading the above? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.