“use strict”; now allows duplicated properties?

﹥>﹥吖頭↗ 提交于 2019-11-28 03:26:13

问题


I just found that in the last Chrome 42 and FF 37.0.2 this lines of code are perfectly legal

"use strict";
var o = { p: 1, p: 2 };

(copy-pasted from MDN )

In IE 10-11 and Opera 28.0.1750 it throws error as expected.

In the same time,

abc=0;

causes error (undeclared variable) as expected.

Does anybody know what caused such change?


回答1:


There is a Bugzilla ticket here. From what I gather (here and other pages I have looked up), duplicate properties are legal in ECMAScript version 6, opposed to ES5, where it is forbidden in strict mode.



来源:https://stackoverflow.com/questions/29936845/use-strict-now-allows-duplicated-properties

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