Javascript - Math pow() Method

The pow() method returns the value of x to the power of y (x^y).

Description

The pow() method returns the value of x to the power of y (x^y).

Syntax

Math.pow(x,y)

Parameter Values

Parameter Require Description
x Required. The base
y Required. The exponent

Return

A Number, representing the value of x to the power of y

Example

Return the value of the number 4 to the power of 3 (4*4*4):

Demo

//display the result of 4*4*4.
console.log(Math.pow(4, 3));/*from  w w w  .  j  a  v a  2  s.  c o  m*/

//Use the pow() method on different numbers:

var a = Math.pow(0, 1);
var b = Math.pow(11, 1);
var c = Math.pow(11, 10);
var d = Math.pow(3, 3);
var e = Math.pow(-3, 3);
var f = Math.pow(2, 4);

var x = a + "\n" + b + "\n" + c + "\n" + d + "\n" + e + "\n" + f;
console.log(x);

Result