In JavaScript, there is a class called math. And it's very useful. You can make many operations, many mathematical operations using the math class, which has many methods that you can use in order to get results easier. So for example, suppose that you have a variable called x, and it's equal to four, and you want the square root of four, which is two, right? The easiest way to get that value is using the math class. And I'm going to show you how you just type math, and then call the method.
And this is as we did before, this is an object, think of it as an object, and it's predefined by a JavaScript engine. So this is something that they have created, and it has methods. So this method is called square root which is QR ti. And I'm going to pass x. And I'm going to store the result result inside the new variable here, I'm going to name it result equals to this. And I'm going to use the console log console dot log and pass the result result.
And now if I say, I'm going to get to because the square root of four is two, now if I want to get the square root of nine, if I change x to nine, and if I save and run, I'm going to get three. So this is how you can get the square root of a number using this square root function. There are many other functions. So for example, there is a function called absolute, which is a BS apps, which is going to get you the absolute value of a number. So for example, if x is minus nine and we want to get the option value of minus nine, which is nine. If we use this absolute function, and we print the result, what I'm going to get is nine.
So this is another important and useful function in JavaScript. There is also a function called sign, which is a sign which is gonna, which is going to bring you the value of this sign. If you studied sine and cosine and a tan in our in high school or in college, you just type sign and for example, we value of 30. If I want to get this value, what I'm going to get is minus 9880. So this is the value of sine if I want to use the cosine C or s, and if I save and run, I'm gonna get point 15 for 25. If I want the tan, if I see one run, I'm gonna get minus six.
So this is how you can use these functions. There is also a very simple function called floor floor, and I'm going to show you what it does. Suppose this number is 30.9. If now I save and run, what I'm going to get is 33. Only 30, because floor is getting is going to round down the number to the nearest nearest floor for that number. So the nearest floor for 430. point nine is 30.
The opposite function is called seal, which is going to round up to the number. And if I save and run, I'm going to get I'm going to get 31 because the nearest number to 30.9 is 31. So all of these are very, very useful. And I'm going to also and if you want more of these functions, just go to the Mozilla as I showed you before website, which has many functions for the math class, which you can use. And by the way, these functions are useful because you don't have to create Your own function, you already have these functions predefined for you. So you don't have to create your own function and write the function from from the beginning and reinvent the wheel.
You already have these functions and they are ready to be used.