问题
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