Matt Matt - 1 year ago 94
Javascript Question

Difference between ECMAScript 2016 exponentiation operator and Math.pow()

What is the benefit to using the ECMAScript 2016 exponentiation operator over the current

? In other words, besides reducing key strokes, what is the difference between

Math.pow(2, 2) => 4
2 ** 2 => 4

Answer Source

None. As you can read in the spec draft, both Math.pow and the ** exponentation operator cast their arguments/operands to numbers and use the very same algorithm to determine the result.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download