浏览器支持在JavaScript中使用保留字作为属性名称 [英] Browser support for using a reserved word as a property name in JavaScript

查看:330
本文介绍了浏览器支持在JavaScript中使用保留字作为属性名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用for作为对象属性名称。它似乎在IE7,IE8,Firefox,Chrome和Opera中运行良好,但显然不在Safari中。

I'm trying to use "for" as an object property name. It seems to work fine in IE7, IE8, Firefox, Chrome and Opera, but apparently not in Safari.

我的理解是ECMAScript 5允许它(如哈希键中的JavaScript关键字)。

My understanding is that ECMAScript 5 allows it (as discussed in JavaScript keywords in hash keys).

我可以获得支持/不支持此功能的浏览器的确定列表吗?

Can I get a definitive list of browsers that support/don't support this somewhere?

编辑:实际上,CoffeeScript对保留字属性名称的自动字符串化使我相信它有效。在正确地重新测试之后,它似乎无法在任何地方工作,所以现在的问题是:是否有任何浏览器允许它按照ECMAScript 5规范进行?

Actually, CoffeeScript's auto-stringification of reserved word property names is what led me to believe that it works. After re-testing properly it doesn't seem to work anywhere, so the question now is: are there any browsers that allow it as per ECMAScript 5 specification?

推荐答案

此处有一个表格显示了对ECMAScript 5功能的浏览器支持: http ://kangax.github.com/es5-compat-table/

There is a table showing browser support for ECMAScript 5 features here: http://kangax.github.com/es5-compat-table/

保留字可用作IE9,Firefox 3.5+和Chrome中的属性名称7+,Safari 5.1 +。

Reserved words can be used as property names in IE9, Firefox 3.5+ and Chrome 7+, Safari 5.1+.

这篇关于浏览器支持在JavaScript中使用保留字作为属性名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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