➤ How to Code a Game
➤ Array Programs in Java
➤ Java Inline Thread Creation
➤ Java Custom Exception
➤ Hibernate vs JDBC
➤ Object Relational Mapping
➤ Check Oracle DB Size
➤ Check Oracle DB Version
➤ Generation of Computers
➤ XML Pros & Cons
➤ Git Analytics & Its Uses
➤ Top Skills for Cloud Professional
➤ How to Hire Best Candidates
➤ Scrum Master Roles & Work
➤ CyberSecurity in Python
➤ Protect from Cyber-Attack
➤ Solve App Development Challenges
➤ Top Chrome Extensions for Twitch Users
➤ Mistakes That Can Ruin Your Test Metric Program
The following code displays the result of 5 raised to power 2, which is equal to 25.
num = 5 ** 2; console.log(num);
The next piece of code displays the square root of 49, that is, 7 raised to 1/2 or 0.5.
num = 49 ** (1/2); console.log(num);
Any number raised to power 0 always produces a result of 1. The below program demonstrate this example.
num = 81 ** 0; console.log(num);
num = 81 ** -2; console.log(num);
num = 81 ** 1.5; console.log(num);
num = 81 ** '0.5'; console.log(num); num1 = 81 ** 'Hello'; console.log(num1);
If any of the operands of the exponential operator is not number type then the exponential operator always produces NaN as result.
num = 'Hello' ** 2; console.log(num); num1 = 'Hello' ** 'World'; console.log(num1);
Exponent Operator in JS vs Math.pow()
The usage is fairly simple, you just need to use the ** symbol between two numbers and it will return the left operand to the power of the right one.
If you enjoyed this post, share it with your friends. Do you want to share more information about the topic discussed above or do you find anything incorrect? Let us know in the comments. Thank you!