Home »
        JavaScript
    
    Math.pow() Method with Example in JavaScript
    
    
    
    
        JavaScript | Math.pow() Method: Here, we are going to learn about the pow() method of Math class in JavaScript with Examples.
        
            Submitted by Shivang Yadav, on February 03, 2020
        
    
    
    JavaScript | Math.pow() Method
   
    Math.pow() is a function in math library of JavaScript that is used to return the value of a number x to the power n (where, x is base and n is exponent.
    
Syntax
    Math.pow(base, exponent);
    Parameters
    
        - base, exponent – represent the values of base and exponent.
Return Value
    The return type of this method is number, it returns the value which is the result of base ^ exponent.
    Values accepted
    Integer, floating-point, numeric string.
    Invalid values
    Non-numeric string, empty variable, empty array all will return NaN (Not a Number).
    Browser support
    Chrome, Internet asinlorer, Mozilla, Safari, Opera mini.
Example 1: Valid values
console.log(Math.pow(5, 4));
console.log(Math.pow(3.14, 4));
console.log(Math.pow(0, 4, ));
console.log(Math.pow("0.65", "-3"));
Output
625
97.21171216000002
0
3.641329085116067
Example 2: Invalid values
Math.pow("Javascript", "IncludeHelp")
Output
NaN
	JavaScript Math Object Methods »
	
	
    
    
    
    
    
  
    Advertisement
    
    
    
  
  
    Advertisement