Math objects and properties in JS

Source: Internet
Author: User

Mention the mathematical formula what believe that a large number of people will be a face ~o (^▽^) o~ but no way, walk on the code this road is doomed to deal with mathematics, learn bar comrades, refueling O (^▽^) o~

The Math object, which provides a mathematical calculation of the data. As an example:

1 <script type= "Text/javascript" >2   var mypi=3   var myabs=math.abs ( -15); 4   document.write (mypi); 5   document.write (myabs); 6 </script>

Operation Result:

3.14159265358979315

The Math object is an intrinsic object that differs from the Date,string object in that it does not need to be created, and that all its properties and methods can be called directly using Math as an object.

Below I put some properties and methods of the math object, so that I can see later, all of the lessons I learned on the Internet, we are interested to see, MU class network is very good, at least for my help very big O (^▽^) o~

Math Object Properties:

Math Object Method:

PS1: For Math.Round () This method, he follows the same distance +∞ principle, that is, when a number, such as 3.5, his distance from 3 and 4 is the same, then return to the larger one, that is, 4. The same,-3.5, the distance-3 and -4, the larger, is-3.

The Ps2:Math.random () method is to return a random number greater than or equal to 0 but less than 1, excluding 1, which is left closed right, and the same as the interception method of substring ().

Math objects and properties in JS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.