**x**” multiplied by itself two times, we can simply write “

**x^2**”, which makes calculation easier. In such cases, using exponents becomes very handy. Moreover, utilizing exponents also allows us to abbreviate something that would otherwise be time-consuming to think about.

This article will discuss the methods to use exponents in JavaScript.

## How to Use/Apply Exponents in JavaScript?

To utilize Exponents in JavaScript, you can use:

- “
**Math.pow()**” Method - “
**Exponentiation Operator (**)**”

We will now go through each of the mentioned approaches one by one!

## Method 1: Use Exponents in JavaScript Using Math.pow() Method

The Math.pow() method returns the value of “**a**” to the power of “**b**” like (a^b). It returns a “**Nan**” value in the case of a negative base and a non-integer base. You can also utilize this method to return the specified power of the provided number.

**Syntax**

Here, “**pow**” refers to the power method, “**base**” refers to the number whose value is to raise, and “**exponent**” is the required value.

Go through the following example for a better understanding of the stated concept.

**Example**

First, we will observe two different cases. First, we will display the base “**7**” with exponent value “**2**” which will work as “**7^2=49**”:

Now, we will verify the “**NaN**” condition by placing a negative base value, and a non-integer exponent value as follows:

The output of the above implementation is given below:

## Method 2: Use Exponents in JavaScript Using Exponentiation Operator(**)

The Exponentiation operator (**) changes the value of the first variable with respect to the assigned second value which will act as power of the first variable. However, it also returns a “**NaN**” under the same circumstances discussed in the previous method. To utilize this operator, you can add (**) in between both operand values where the first value will act as a “**base**”, and the operand value after the exponentiation operator (**) will be raised according to the added base.

**Syntax**

Here, “**x**” refers to the value or a variable, and “**y**” is the power value that needs to be applied at x.

**Example**

Firstly, we will declare a variable named “**base**” and store the value “**2**” in it:

Next, we will raise the assigned value of the base variable to the power “**3**” using the exponentiation operator “**”. Here, in place of the base variable, you can also add any integer value directly:

The corresponding output, in this case, will be:

We have provided the simplest methods to use exponents in JavaScript.

## Conclusion

To use Exponents in JavaScript, you can utilize the “**Math.pow()**” method for assigning an exponent power to a base value and “**Exponentiation Operator(**)**” for raising the base value(on the left) to the provided exponent value(on the right) separated by (**). This write-up has explained the methods to use exponents in JavaScript.