js对象属性名书写方式

来源:互联网 发布:淘宝上的啤酒是真的吗 编辑:程序博客网 时间:2024/05/02 02:51

Notation of Keys

var test = {    'case': 'I am a keyword so I must be notated as a string',    delete: 'I am a keyword too so me' // raises SyntaxError};

Object properties can be both notated as plain characters and as strings. Due to another mis-design in JavaScript's parser, the above will throw aSyntaxError prior to ECMAScript 5.

This error arises from the fact that 
delete
 is a keyword; therefore, it must be notated as a string literal to ensure that it will be correctly interpreted by older JavaScript engines.

原创粉丝点击