Your Search Results



    The Math.pow() function returns the base to the exponent power, that is, baseexponent.


    Math.pow(base, exponent)


    The base number.
    The exponent used to raise the base.


    Because pow() is a static method of Math, you always use it as Math.pow(), rather than as a method of a Math object you created (Math is no constructor).


    Example: Using Math.pow()

    // simple
    Math.pow(7, 2);    // 49
    Math.pow(7, 3);    // 343
    Math.pow(2, 10);   // 1024
    // fractional exponents
    Math.pow(4, 0.5);  // 2 (square root of 4)
    Math.pow(8, 1/3);  // 2 (cube root of 8)
    Math.pow(2, 0.5);  // 1.412135623730951 (square root of 2)
    Math.pow(2, 1/3);  // 1.2599210498948732 (cube root of 2)
    // signed exponents
    Math.pow(7, -2);   // 0.02040816326530612 (1/49)
    Math.pow(8, -1/3); // 0.5
    // signed bases
    Math.pow(-7, 2);   // 49 (squares are positive)
    Math.pow(-7, 3);   // -343 (cubes can be negative)
    Math.pow(-7, 0.5); // NaN (negative numbers don't have a real square root)
    // due to "even" and "odd" roots laying close to each other, 
    // and limits in the floating number precision, 
    // negative bases with fractional exponents always return NaN
    Math.pow(-7, 1/3); // NaN 


    Specification Status Comment
    ECMAScript 1st Edition. Standard Initial definition. Implemented in JavaScript 1.0.
    ECMAScript 5.1 (ECMA-262)
    The definition of 'Math.pow' in that specification.
    ECMAScript 6 (ECMA-262)
    The definition of 'Math.pow' in that specification.
    Release Candidate  

    Browser compatibility

    Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
    Basic support (Yes) (Yes) (Yes) (Yes) (Yes)
    Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
    Basic support (Yes) (Yes) (Yes) (Yes) (Yes) (Yes)

    See also

    Document Tags and Contributors

    Contributors to this page: evilpie, Sheppy, Marcoos, fscholz, Mingun, ethertank, egiw, Mgjbot, Maian, Dria, Kyodev, sanderd17
    Last updated by: sanderd17,