A Perplexing Javascript Parsing Puzzle

29 points by hwayne


fanf

I think part of the answer to the mystery is,

roryokane

Here’s an explanation of the slightly simpler puzzle that this puzzle initially seemed equivalent to:

What does this print?

x
= 1
x -->
0

The answer to this puzzle is true. The reasons:

So that program is equivalent to this:

x = 1;
x-- > 0

The last expression evaluates to whether x is greater than zero (and then sets the value of x to zero). 1 is greater than 0, so it evalutes to true.

olliej

Oh right, I remember implementing those blasted comments in JSC many many many years ago.

I misread the question though as having --> 0 being “this is the output” rather than this is still part of the input. To be fair to the author, I’m not sure how they could possibly right this example in any other way, and this is just muppetry on my part :D