David Dorward wrote:
On Oct 9, 12:32 pm, Steve <stephen.jo...@googlemail.comwrote:
>[Object initializer]
and why is no comma required after the last line etc.
Its forbidden, IIRC, not simply 'not required'.
It's not forbidden. The specification does not define the mechanism
explicitly, but it includes the provision for conforming implementations
to deviate from the specified program syntax (section "2 Conformance").
It is unwise to write the comma there because ECMAScript implementations
(particularly JavaScript and JScript) differ here; that is not an issue when
the used implementation is known (say in a Firefox extension).
Its a separator not a terminator
Correct.
(so it goes between property/value pairs, not after them).
In JavaScript 1.5 (in contrast to JScript),
var foo = {bar: "baz",};
is semantically equal to
var bla = {foo: "baz"};
It will show a warning in Geckos, though:
| Warning: trailing comma is not legal in ECMA-262 object initializers
| Source file: javascript
: var foo = {bar: "baz",};
| Line: 1, Column: 23
| Source code:
| var foo = {bar: "baz",};
PointedEars
"Use any version of Microsoft Frontpage to create your site. (This won't
prevent people from viewing your source, but no one will want to steal it.)"
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>