Now, what are Math function objects?
Let's take a real-time example of Math function in JS.
Math.PI;// returns 3.141592
I hate mathematics. But I can't deny that mathematical is a prime part of academics. In programming, there are many situations that may come where we have to rely on mathematical tasks.
I was developing my B.tech project. Meanwhile, there was a need to process numerical information for performing some calculations. That situation tend me to search for the shortcuts of mathematical tasks in programming.
Benefits of Math Functions:
ii) The developers will save their time because they do not need to spend their time on accessing properties and methods of Math object to perform a task on numbers.
<!DOCTYPE html> <html> <body> <h2> Math.abs() in JS</h2> <p>A simple example illustrating Math.abs(x) returning the absolute value in the output:</p> <p id="demo"></p> <script> document.write(Math.abs(54+67)); </script> </body> </html>
The syntax which has been used while writing the above-mentioned program of Math.abs is written below:
math.ceil() function is applicable in the conditions when there is a need to return the smallest numerical values greater than a given number in the module. In other words, we can say to round up any numeric numbers to their nearest value towards the upward direction, One can use math. ceil function.
The output appeared as given below:
The output being appeared while executing the above program is given below:
The above-mentioned syntax consists of a base (P) and exponent (Q) to represent base and exponent values respectively.
<!DOCTYPE html> <html> <body> <script> document.writeln(Math.pow(7,9)+"<br>"); document.writeln(Math.pow(8,2.7)); </script> </body> </html>
Output of the above-written program has been appeared as:
Let's understand the concept of Math.random() through a simple program
The output appeared as:
If you want any other functions to get explained, please comment below . I will surely revert back to you accordingly.