Exponentiation(Math.pow() 或)

Exponentiation 使第二个操作数成为第一个操作数(a b ) 的幂。

var a = 2,
    b = 3,
    c = Math.pow(a, b);

c 现在是 8

Version > 6

第 3 阶段 ES2016(ECMAScript 7)提案:

let a = 2,
    b = 3,
    c = a ** b;

c 现在将是 8

使用 Math.pow 查找数字的第 n 个根

找到第 n 个根是提升到第 n 个幂的倒数。例如 25 的力量是 3232 的第 5 根是 2

Math.pow(v, 1 / n); // where v is any positive real number 
                    // and n is any positive integer

var a = 16;
var b = Math.pow(a, 1 / 2);  // return the square root of 16 = 4
var c = Math.pow(a, 1 / 3);  // return the cubed root of 16 = 2.5198420997897464
var d = Math.pow(a, 1 / 4);  // return the 4th root of 16 = 2