Why is this JavaScript not interpreted as a code block when semi-colon is used?

旧时模样 提交于 2019-12-05 08:22:05

Why does this occur with the semi-colon but not without it?

Chrome uses a very simple test to see whether a line is an object literal or not: Does the line start with a { and end with a }? If yes, the line is evaluated as an expression.

{ prop: p } = { prop: 'prop' } passes that test, but { prop: p } = { prop: 'prop' }; does not.


See Odd behaviour of comparison of object literals for more info (different input, same reason).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!