Math
is a built-in object in JavaScript that contains different methods and properties used to perform mathematical operations. It contains the pow()
function, which is used to compute the power of a specified number with a specified value.
Math.pow(base, power);
base
: This represents the number to be raised with power. It is of Number
type.
power
: This represents the power value. It is of Number
type.
Number
in JavaScript is a 64-bit double-precision value which is the same asdouble
in C# or Java.
Number
: It returns a base
raised to the power
, and its type is Number
.
NaN
: The function returns this if
base
< 0 and power
is fractional.
console.log("pow(-0.16,2) = " + Math.pow(-0.16,2));console.log("pow(0,0) = " + Math.pow(0,0));console.log("pow(-2,-4) = " + Math.pow(-2,-4));console.log("pow(2,4) = " + Math.pow(2,4));console.log("pow(-2,0.4) = " + Math.pow(-2,0.4));