How to use Exponentiation (**) Operator In Javascript
This method can also be utilized to find the power of the first operator raised to the second operator, & it is denoted by a double asterisk(**) symbol.
Syntax
Base**Power
Example: In this example, we will use the JavaScript ** operator to get 17 to power 3.
// Base number input
let n = 17;
let power = 3;
// Calculate and display output
console.log(n**power);
Output
4913
JavaScript Program to Compute Power of a Number
In this article, we will demonstrate different approaches for computing the Power of a Number using JavaScript.
The Power of a Number can be computed by raising a number to a certain exponent. It can be denoted using a^b, where the ‘a’ represents the base number & the ‘b’ represents the number to which the power is to be raised. These programs will have input numbers and power and will show the resulting output. There are various techniques to calculate the power of a number, which are described below with their illustrations.
Table of Content
- Using JavaScript Loops
- Using Recursion
- Using the Math.pow() Method
- Using JavaScript Exponentiation (**) Operator
- Using Exponentiation by Squaring