This is the 14th day of my participation in the November Gwen Challenge. Check out the event details: The last Gwen Challenge 2021

Js Math type

Absolute value.

Math.abs(x) 
Copy the code

Returns the largest value of the argument. NaN is returned if any of the parameters are NaN or cannot be converted to a numeric type

Math.max(a)
/ / a: parameters
Copy the code

Returns the smallest value of the argument. NaN is returned if any of the parameters are NaN or cannot be converted to a numeric type

Math.min(a) / / a: parameters
Copy the code

Returns a random number between 0 and 1

Math.random()
/ / 0.2356786415348674
Copy the code

Round a parameter up to a value down. For example, 1.5 would return 2

Math.round()
Copy the code

Calculate the arcsine of the parameter

Math.asin(x)  / / x: parameters
Copy the code

Computes the arctangent of the parameter

Math.atan(x)  / / x: parameters
Copy the code

It’s the Angle that we go through when we go counterclockwise to the point (X, y)

Math.atan2(y, x)
//x: specifies the x coordinate of the point.
//y: specifies the y coordinate of the point.
Copy the code

The argument is rounded up, which returns the nearest integer greater than or equal to the function argument. It performs a different operation than math.round (), which is always rounded up, whereas math.round () can be rounded up or down to the nearest integer. Also note that it does not round negative numbers to smaller negative numbers, but to 0.

Math.ceil(x)
//x is any number or expression

/ / such as
Math.ceil(2.99) / / output 3.0
Math.ceil(2.09) / / output 3.0
Math.ceil(1.0) / / output 1.0
Math.ceil(-2.99) / / output - 2.0
Copy the code

Computes the cosine of the specified value, returning -1 and 1

Math.cos(x)
//x is the radian of an Angle
Copy the code

Round down the argument, return a value less than the input argument value, and is the closest integer to the argument. It can round a floating-point value down to the nearest integer, unlike math.round (), and it still turns negative numbers into smaller ones, not zero

Math.ceil(x)
//x is any number or expression

/ / such as
Math.floor(2.99) / / output 2.0
Math.floor(2.09) / / output 2.0
Math.floor(1.0) / / output 1.0
Math.floor(-2.99) / / output - 3.0
Copy the code

Here are some common values for the Math attribute, hopefully useful to you