JS summarizing 3:javascript's Math object

Source: Internet
Author: User

Math Object

The Math object is used to perform mathematical tasks.

The Math object is not a class of objects like Date and String, so there is no constructor for math ().

Common methods of Math

var n1=1234;
var n2=12.34;
var n3=56.78;
var n4=12.34;


1 var n5=math.max (N1,N4); The maximum value of two digits is taken.

2 var n5=math.min (N3,N1); Return is the minimum value of two digits

3 var n5=math.ceil (N4); The ceiling function takes an integer up

4 var n5=math.round (N4); Rounds the number to the nearest integer.

5 var n5=math.pow (N1,N2); Returns the N2 of N1

6 var n5=math.random (23); Returns the random number between 0-23

alert (N5);

JS summarizing 3:javascript's Math object

Related Article

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.