The math object is a predefined JavaScript object, which provides some additional functionality for working with numbers. For example, if you needed to get the sine or cosine or tangent, those would be available in the math object. But the math object also has some other methods that you may use more frequently than those. Let's take a look at what they are. So first off random math dot random, returns a random number between zero and one that can be used if you are in a situation where you need to generate random numbers. Now notice that notice how the structure of this is we have the math object, then we use the dot notation.
And then we use the method that we want to access and then this will return a random number. Next one is round if you need to round a number Number, math dot round and then inside the parentheses you would place the number that you want to round. Math dot floor is very similar, it will round down to the integer value. Math dot ceiling will round up to the integer value. We also have math dot min and math dot max. Basically what these two methods do is they will return the minimum number you give it a list of numbers, list of values and it will return the minimum value or the maximum value depending on which one you use.
So let's take a look at how these work. So I'm going to create a few variables. I'm going to use the comma so I can create multiple variables at once. I mentioned this in an earlier movie. Final variable I'm going to create is going to have a value of negative 10. So we have three variables.
Now, first, let's take a look at math dot math dot random. Math dot random, we don't have to pass anything to it, it simply returns a random number between zero and one. We then use that number within our programming if we're trying to get something that's random. Some programming languages allow you to specify a range of what of what you want the random number from. in JavaScript, you would need to add the code to do that if you need that type of functionality. Okay, let's look at math dot round.
Inside the parentheses, I'm going to put the num variable and it's going to round and since it's past five point five, it rounds up to six. So you can imagine math dot ceiling is going to do the same type of thing where math dot floor is going to go down to five. All right, let's take a look at math dot min. So like I said, we specify different values inside the parentheses and it will return the one that is the lowest. So negative 10 is the loss. Let's look at math dot max.
This time in addition to the variables that I've created, I'm going to add just a straight number as well. And that number is higher than any of the variables that I have. Fine. So there's a few of the methods that are available with the math object. As you increase your abilities in JavaScript programming, you'll find situations where you'll need to access some of these methods. Okay, let's take a look at the date object.