Recently, working with JavaScript in Developer Tool, I found strange feature. Chrome accepts any code between opening bracket with operator (plus, minus sign) and operator with closing brackets and executes it, like this:
I didn't find this behaviour in another browsers, just in Chrome.
Maybe it's a feature, but why and how it works, can it be problem with JavaScript engine?
This happens because Chrome wraps the code you enter in the console in the following construction:
So, when you enter something like
} 10 {
, the code evaluates to:which is empty
with
block, a number, and empty structural block.__commandLineAPI
is the internal object that contains Chrome Command Line API.This is the way chrome evaluates your input:
So once your input is
}{
it becomesNext input
}-+{
becomesAnd so on.