Uncaught SyntaxError: Unexpected token instanceof (with Chrome Javascript console)

后端 未结 4 982
挽巷
挽巷 2020-12-11 18:58

I am surprised that the following code when input into the Chrome js console:

{} instanceof Object

results in this error message:

4条回答
  •  Happy的楠姐
    2020-12-11 19:36

    {}, in that context, is a block, not an object literal.

    You need change the context (e.g. by wrapping it in ( and )) to make it an object literal.

    ({}) instanceof Object;
    

提交回复
热议问题