TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

JavaScript Math pow() Method

JavaScript Math pow() Method with example, javascript math methods, abs() method, round() method, ceil() method, floor() method, pow() method, random() method, sqrt() method, max() method, min() method, log() method, sin() method, cos() method, tan() method etc.

<< Back to JAVASCRIPT

JavaScript Math pow() method

The JavaScript math pow() method returns the base to the exponent power such as baseexponent. In other words, the base value (x) is multiplied with itself exponent times (y).

Syntax

The pow() method is represented by the following syntax:

Math.pow(base,exponent)

Parameter

Base - The base number.

Exponent - The number used to raise the base.

Return

The value of base to the power of exponent.

JavaScript Math pow() method example

Here, we will understand pow() method through various examples.

Example 1

Let's see a simple example to print the power of given number.

<script>
document.writeln(Math.pow(2,3)+"<br>");
document.writeln(Math.pow(5,1.4));
</script>
Test it Now

Output:

8
9.518269693579391

Example 2

Let's see an example to understand the pow() method with different test cases.

<script>
document.writeln(Math.pow(2,-3)+"<br>");
document.writeln(Math.pow(-3,2)+"<br>");
document.writeln(Math.pow(-5,1.4)+"<br>");
document.writeln(Math.pow(5,-1.4));
</script>
Test it Now

Output:

0.125
9
NaN
0.1050611121761507

Example 3

Let's understand the pow() method with your own test cases.

<script>
function display()
{
  var x=document.getElementById("base").value;
  var y=document.getElementById("exp").value;
  
  document.getElementById("result").innerHTML=Math.pow(x,y);
}
</script>
<form>
Base: <input type="text" id="base"><br>
Exponent: <input type="text" id="exp"> <br>
  <input type="button"  onclick="display()" value="submit">
</form>
<p><span id="result"></span></p>
Test it Now
Next TopicJavaScript Math




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf