() brackets, what does it do in the statement of ({__proto__: []} instanceof Array) in JavaScript
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In JavaScript, the following gives an error: { __proto__: [] } instanceof Array; If I surround it in (brackets) it has no error: ({ __proto__: [] } instanceof Array); Why is this? 回答1: When the interpreter sees a { , by default, it will think that you're declaring a new block, such as { console.log('foo'); } As a result: { __proto__: [] } instanceof Array doesn't make much sense - you can't instanceof a block. But when it's wrapped in parentheses, the interpreter knows to expect a value inside the parentheses, not a block - so it evaluates