Built-in objects in JavaScript -8-math-3

Source: Internet
Author: User

Learning Goals

1. How to master the Math object:

Min()

Max()

Ceil()

Floor()

Round()

ABS()

Math.min ()

Grammar:

Math.min (num1,num2,... numn)

Function:

Find the minimum value in a set of numbers.

return Value: Number.

Math.max ()

Grammar:

Math.max (num1,num2,... numn)

Function:

Find the maximum value in a set of numbers.

return Value: Number.

Math.ceil ()

Grammar:

Math.ceil (num)

Function:

Rounding up, which returns the smallest integer greater than Num.

return Value: Number.

Math.floor ()

Grammar:

Math.floor (num)

Function:

takes an integer down and returns the integer portion of Num.

return Value: Number.

Math.Round ()

Grammar:

Math.Round (num)

Function:

Rounds an integer to the nearest integer.

return Value: Number.

Math.Abs ()

Grammar:

Math.Abs (num)

Function:

returns num is the absolute value.

return Value: Number

Learning Goals

1. grasp the random () method of the Math object

2. encapsulates a function that evaluates to a random integer between N and M.

Learning Goals

1. grasp the random () method of the Math object

2. encapsulates a function that evaluates to a random integer between N and M.

Math.random ()

Grammar:

Math.random ()

features :

Returns a random number greater than or equal to 0 less than 1 .

return Value: Number.

Description

The formula for finding a random integer between N and m :

Random=math.floor (Math.random () * (m-n+1) +n);

Built-in objects in JavaScript -8-math-3

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.