- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the use of Math.pow() method in JavaScript?
Math.pow()
Math.pow() function in JavaScript is used to get power of a number i.e, the value of number raised to some exponent. This method accepts two parameters one is base and the other is exponent. It doesn't matter what kind of parameters do we use such as integers, fractions, negatives etc., it can take any value and proceeds the operation.
syntax
Math.pow(base, exponent)
Example-1
In the following example, we are taken two positive values .The first parameter(base) is 9 and second parameter(exponent) is 3. Using Math.pow() we are going to find 9 to the power of 3.
<html> <body> <script> document.write(Math.pow(9, 3)); </script> </body> </html>
Output
729
Example-2
Using this method we can also find square roots, cube roots etc. Following example is used to demonstrate how to find cube root of a provided number.
<html> <body> <script> document.write(Math.pow(27, 1/3)); </script> </body> </html>
Output
3
Example-3
Following code demonstrates how to find power of a negative number.
<html> <body> <script> document.write(Math.pow(-9, 3)); </script> </body> </html>
Output
-729
- Related Articles
- Math.Pow() Method in C#
- Math.pow() function in JavaScript
- What is the use of weakSet.has() method in JavaScript?
- What is the use of Object.is() method in JavaScript?
- What is the use of Atomics.store() method in JavaScript?
- What is the use of Object.isFrozen() method in JavaScript?
- What is the use of _.size() method in JavaScript?
- What is the use of test() method in JavaScript?
- What is the use of forEach() method in JavaScript?
- What is the use of Array.Reduce() method in JavaScript?
- What is the use of Array.Some() method in JavaScript?
- What is the use of Array.Find() method in JavaScript?
- What is the use of Array.findIndex() method in JavaScript?
- What is the use of Math.abs() method in JavaScript?
- What is the use of substr() method in JavaScript?

Advertisements