您的位置:首页 > Web前端 > JavaScript

js对象属性名书写方式

2011-10-17 09:04 357 查看


Notation of Keys

[code]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 a
SyntaxError
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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: