Home » JavaScript Tutorial

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);

Parameter(s):

  • 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





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.