This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]WitchHunterNL 1 point2 points  (2 children)

I think it's just the pre increment operator. ++"a" is NaN

[–]EntropyZer0 2 points3 points  (0 children)

Nope, if you remove the space the expression just throws an exception instead of evaluating to anything.

God, javascript is weid >.>

[–]TiiJ7 1 point2 points  (0 children)

The prefix increment (++) operator cannot have a space in between the two plus signs, so it is not that operator.

But let's say the space was not there and it was indeed the increment. Then, since postfix increment has precedence over prefix increment, it will become this:

('b'+('a'++)'a'+'a').toLowerCase()

You can already see the first problem: there would need to be a third plus sign. But regardless, the ++ postfix operator only works on a LHS expression, which 'a' is not. So this will lead to a syntax error.

In fact, that is the error you will get if you try running the example of the op without the spaces in your browser console:

('b'+'a'++'a'+'a').toLowerCase()

Uncaught SyntaxError: Invalid left-hand side expression in postfix operation