Why does {} == false throw an exception?
问题 In IE and Chrome, typing this into the JavaScript console throws an exception: {} == false // "SyntaxError: Unexpected token ==" However, all of these statements are evaluated with no problem: false == {} // false ({} == false) // false var a = {}; a == false // false Is this intentional behavior? Why does this happen? 回答1: In the console, when you start a statement with {} , you are not creating an object literal, but a code block (i.e. the same block as you would make with an if statement