So I run the same code 5=6
on both chrome and node this of course produces an error. But look at the error type!
On chrome it's a SyntaxError
on node ReferenceError
.
Well that's odd. For one thing cause both use v8, for another because well...you'd think this would be defined in the spec, so someone has to be wrong.
The same thing happens with strings. Same thing when running js outside of the chrome console as a script. Same thing when running outside of the node console as a script.
Someone suggested that it might be due to differences in boxing since Number(5) = 6
is a ReferenceError
on both but that's just the case for any fn() = _
. And if that is the case, then it still doesn't explain why the behavior is different in the two engines.
So what's the correct (as per the spec) thing to do here? Who is wrong and why are the two engines giving me different errors?