If you put }!{ in your JavaScript console in Chrome, as a result you will get false.
Why don’t we get an error?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The reason for this behaviour is because Chrome wraps anything you enter into the console with another piece of code.
The code it wraps with (at the time of writing) is as follows:
Entering
}!{closes the code block brace, and makes a new (negated) object at the end.As you can see for youself in the console
!{}returnsfalse.I went through quite a lengthy investigative process to find the answer to this, my original comments are preserved below
Original Answer:
Just a theory; I imagine the code entered in the console being called inside a function
function execUserCode() { code }What you’re doing is creating
function execUserCode() { }!{ }The console is returning the last result, which is actually
!{ }=falseEdit:
Lots of comments about how this is probably wrong. I agree. It’s just a theory.
I like these kind of puzzles so I had a dig through the Chromium source, it’s a bit much for me but I’ll leave some pointers in case anyone else has a stab.
The JS console is called the “inspector” and can be found here:
chromium/src/third_party/WebKit/Source/WebCore/inspector/I’ve been looking at
inspector/front-end/ConsoleView.jsand I think I found a bit of where the user code is executed.The reason!
Little brainwave. I did this in the console
Result:
I was close, but now we have the answer 🙂
The code is generated in
chromium/src/third_party/WebKit/Source/WebCore/inspector/InjectedScriptSource.jscurrently around line 440.