Introduction
Exponentiation refers to a mathematical process of multiplying a number by itself, raised to the power of another number.
...
For further actions, you may consider blocking this person and/or reporting abuse
There is one big difference between them.
Math.pow
only works for regular numbers.**
also works forBigInt
s.To quote the MDN page on **:
You're wrong, there is one big difference
Math.pow()
works only on number but**
operator works also for BigInt.Yes you are right, I meant a big difference for the daily basis work.
Anyway, I am going to add this tip.
Never knew they added a Math function for exponents. IMO using
**
is better since its like that in other langues like Python, Ruby and probably others. ThoughMath.pow()
is also used in Java and they dont have**
Agree with you,
**
is better and easier.Nice!
Also good to know, contrary to what some people may think, the
^
operator isn't exponentiation at all (it is sometimes used as such, for example in the google calculator), its a XOR operator and will yield totally different results!Thanks, good tip!
Also of note would be that performance wise these two methods seem to be equal (within a small margin)
Math.pow vs ** vs *
Thanks for sharing - I knew about
Math.pow()
, but not about**
.Glad to know it helps!
Neat!