Is "^" a shorthand for Math.pow()?

actionscript, actionscript-3

Solution

Is there a difference between `4 ^ 2` and `Math.pow(4, 2);`

Yes, `^` is the binary xor operator, whereas `Math.pow(x, y)` raises `x` to the `y` power.

410 ^ 210 == 610 // 01002 xor 00102 == 01102

Math.pow(4, 2) == 16 // 42 == 16

As of ES2016, the shorthand for `Math.pow(x, y)` is `x**y`

console.log('Using `Math.pow(4, 2)`:', Math.pow(4, 2))
console.log('Using `4**2`:', 4**2)

Problem

Is there a difference between `4 ^ 2` and `Math.pow(4, 2);` in Actionscript 3?

Original source