JavaScript & jQuery Tutorials

JS Home Right Arrow JS Reference Right Arrow Math Right Arrow pow()

pow()  Math  class method

Description

Returns base to the exponent power.  baseexponent

  • Like all class methods pow() should be used on the class rather than an instance of the class.

Syntax


Signature Description
Math.pow(base.exponent)Returns base to the exponent power.  baseexponent

Parameters


Parameter Description
baseThe base number:
  • Negative numbers returns NaN.
  • Non-numeric strings returns NaN.
  • Passing no parameter returns NaN.
  • Passing null returns 0.
exponentThe base number:
  • Non-numeric strings returns NaN.
  • Passing no parameter returns NaN.
  • Passing null returns 1.

Examples

The code below displays pow() usage.



// Store results in an array.
var powValues = new Array(10);
powValues[0] = Math.log(-7,2);
powValues[1] = Math.pow(7,-2);
powValues[2] = Math.pow(0,5);
powValues[3] = Math.pow(5,0);
powValues[4] = Math.pow('0.75','2');
powValues[5] = Math.pow('a string',6);
powValues[6] = Math.pow(6,'a string');
powValues[7] = Math.pow();
powValues[8] = Math.pow(null,4);
powValues[9] = Math.pow(4,null);

alert(powValues);  

Press the button below to action the above code:



Related Tutorials

JavaScript Advanced Tutorials - Lesson 4 - Math




  

go to home page Homepage go to top of page Top