Power operator, why does -2**3 throws?

medikoo medikoo+mozilla.org at medikoo.com
Tue Oct 18 07:20:37 UTC 2016


I must say throwing here, instead of relying on math dictated operators
precedence looks really bad.
It's very surprising to those well experienced with the language, and 
totally inconsistent with how operators worked so far (there is no previous
case where one will throw for similar reason).

Also argument that it's inconsistent with Math.pow(-2, 2), is total miss in
my eyes.
I believe to most programmers `Math.pow(-2, 2)`, translates to `(-2)**(2)`
and not to `-2**2`, 
same as `Math.pow(a ? b : c, 2)` intuitively translates to `(a ? b :
c)**(2)` and not to `a ? b : c**2`




--
View this message in context: http://mozilla.6506.n7.nabble.com/Power-operator-why-does-2-3-throws-tp359609p359731.html
Sent from the Mozilla - ECMAScript 4 discussion mailing list archive at Nabble.com.


More information about the es-discuss mailing list