“严格使用”;现在允许重复的属性? [英] "use strict"; now allows duplicated properties?

查看:127
本文介绍了“严格使用”;现在允许重复的属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚发现,在上次的Chrome 42和FF 37.0.2这行代码是完全合法的

 use严格; 
var o = {p:1,p:2};

(复制粘贴于

同时,

  abc = 0; 

会导致错误(未声明的变量)

有人知道是什么原因导致了这样的变化吗? 有一个Bugzilla ticket 。从我收集的内容(在这里和其他页面上查到)中,重复的属性在ECMAScript版本6中是合法的,与ES5相反,在严格模式下被禁止。


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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆