var obj = {
foo: 'bar',
default: 'default_value'
}
Firefox 3.5.3 creates obj with properties foo and default.
IE reports syntax error "Expected identifier, string or number", same
or similar syntax error occurs on Safari, Chrome and Opera. By placing
default into quotes we are making the code valid for all browsers in
question:
var obj = {
foo: 'bar',
'default': 'default_value'
}
My question is if it is a Gecko bug, a convenience extension or the
proper implementation by ECMA with others being wrong on that?
This is a spidermonkey 'bug' in the default is in the list of future
reserved words by the ES262 (ECMAScript 3) spec.
Wether its actually a problem or not is another matter of course.
Not a bug, yes a convenience, and proper implementation of ES5 (after
ES3.1 and ES4, which both allowed reserved words to be used in
property-name contexts). Also a proper extension to ES3, which allows
such syntactic extensions (see chapter 16).
IE has yet to ship the ES5 JScript implementation I've seen demo'ed at
Ecma TC39 meetings.
> This is a spidermonkey 'bug' in the default is in the list of future
> reserved words by the ES262 (ECMAScript 3) spec.
No, 'default' is not future-reserved in ES2 or ES3 -- it's used in
switch statements.
/be
Brendan Eich wrote:
> Not a bug, yes a convenience, and proper implementation of ES5 (after
> ES3.1 and ES4, which both allowed reserved words to be used in
> property-name contexts). Also a proper extension to ES3, which allows
> such syntactic extensions (see chapter 16).
>
> IE has yet to ship the ES5 JScript implementation I've seen demo'ed at
> Ecma TC39 meetings.
Thank you for your clarification.