EN
Uncaught SyntaxError: Unary operator used immediately before exponentiation expression. Parenthesis must be used to disambiguate operator precedence - Google Chrome
1 points
This code:
xxxxxxxxxx
1
console.log( -2 ** 4 ); // Syntax error!
Throws exception:
Uncaught SyntaxError: Unary operator used immediately before exponentiation expression. Parenthesis must be used to disambiguate operator precedence
If base
value is negative it should be placed in brackets.
In our case we have -2
, so we put it into brackets, like this: ( -2 )
and it solves the problem.
Example:
xxxxxxxxxx
1
console.log( (-2) ** 4 ); // 16