“严格使用”;现在允许重复的属性? [英] "use strict"; now allows duplicated properties?
本文介绍了“严格使用”;现在允许重复的属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
use严格;
var o = {p:1,p:2};
(复制粘贴于 同时, 会导致错误(未声明的变量)
abc = 0;
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?
解决方案
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.
这篇关于“严格使用”;现在允许重复的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文