I was fiddling around with different things, like this
var a = 1, b = 2;
alert(a + - + - + - + - + - + - + - + b); //alerts -1
and I could remove the spaces, and it would still work.
a+-+-+-+-+-+-+-+b
Then I tried
a + + b
It ran and evaluated to 3, but when I removed the spaces, (a++b
) it wouldn't run, and it had a warning which read "Confusing plusses."
I can understand that in cases like
a+++++b
which could be interpreted as any of the following
(a++) + (++b)
(a++) + +(+b)
a + +(+(++b))
a + +(+(+(+b)))
that it would be confusing.
But in the case of
a++b
the only valid way to interpret this, as far as I can tell, is
a + +b
Why doesn't a++b
work?