Javatpoint Logo
Javatpoint Logo

JavaScript Exponentiation Operator

The output of raising a first input value to the power of the second input value is returned by the exponentiation (**) operator. It is the same as Math.pow(), except that it also accepts BigInts as operands.

The javascript exponentiation operator is used to calculate the exponential value of the given power data. It is the replacement of the Math.pow() function for better operation. We can use positive, negative, and number input data for calculations.

Syntax

The following syntax is the symbol to use the exponentiation operator.

Or

  • The "First_value" is the input value of the operation.
  • The "second_value" is the power of the given input value.
  • The first and second input values accept as number data per requirement.

Drawback of the Math.pow() Operator

  • The math.pow() operator does not allow bigint data for the calculation. It accepts a value and converts it into an integer value.
  • The exponentiation (**) operator is used given value as a number type. Other data neglect or does not use for the calculation.
  • The math.pow() operator does not use the bigint value. The exponentiation operator accepts the bigint value.
  • Let's see the example of the Math.pow() and exponentiation (**) operator. The input values are different for both operators.

Output

The following image shows the different input values and output data.

JavaScript Exponentiation Operator

Examples

The following examples display the exponentiation operator and its working procedure.

Example 1:

The basic exponentiation operator and its working procedure are shown below.

Output

The basic value of the operator shows in the output image.

JavaScript Exponentiation Operator

Example 2:

The basic exponentiation operator with a negative input value shows below.

Output

The basic values of the operator are shown in the output image.

JavaScript Exponentiation Operator

Example 3: the basic exponentiation operator with large size values shows in the below example.

Output

The basic value of the operator shows in the output image.

JavaScript Exponentiation Operator

Example 4:

The example of the multiple exponentiation operator with input data is below.

Output

The basic value of the operator shows in the output image.

JavaScript Exponentiation Operator

Example 5:

The basic exponentiation operator with bigint data show in the below example.

Output

The basic value of the operator shows in the output image.

JavaScript Exponentiation Operator

Example 6:

The basic exponentiation operator with other operators shows below.

Output

The basic value of the operator shows in the output image.

JavaScript Exponentiation Operator

Syntax Error for the Exponentiation Operator

The negative value needs to write in a simple bracket. If we can use it as it is like positive input data, then javascript shows syntax error as a console.

Let's see the example of the syntax error of the exponentiation operator.

Output

The syntax error of the operator shows in the output image.

JavaScript Exponentiation Operator

Conclusion

The exponentiation operator is the most advance and latest operator to calculate and get exponential value. It is an easy, simple, and user-friendly JavaScript operator for users and developers.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA