Skip to content

power ​

The power() method raises a number to a given exponent. It calculates the value of a number multiplied by itself a certain number of times.

Interactive example ​

Syntax ​

Classic signature ​

typescript
function power<
	GenericInput extends number
>(
	input: GenericInput,
	exponent: number
): number

Curried signature ​

typescript
function power<
	GenericInput extends number
>(
	exponent: number
): (input: GenericInput) => number

Parameters ​

  • input: The base number to raise to a power (classic signature only).
  • exponent: The exponent to which to raise the number.

Return value ​

returns the result of input raised to the power exponent. Equivalent to value ** exponent or Math.pow(value, exponent).

See also ​

  • multiply - Multiplies two numbers
  • sqrt - Calculates the square root

Sources ​

Released under the MIT license.