"Tested only in FireFox" signature error
Thursday, 22. September 2005, 21:26:07
The error is to add a final comma inside an ECMAScript object literal:
var myObject = { property:'value' , }Last seen in here and in an ad-hoc Chinese IME JavaScript demo (!) which I can't re-locate at the moment.
Try it out with the following bookmarklet:
javascript:try{eval("var a={a:'a',};");alert('Wrong behaviour!')}catch(e){alert('Correct behaviour!')}A first-class example of how a minor browser sloppiness creates a serious compatibility problem.
By Waldo, # 4. October 2005, 06:32:46
hurray SpiderApe!
By xErath, # 6. January 2006, 04:47:25
By hallvors, # 6. January 2006, 14:46:01
According to the spec only commas preceded by void elided elements add to the length of the array, not the last one that's followed by a void elided element. If you follow the Semantics with the examples [], [,] and [,,] you'll see that Mozilla is correct.
By cearrach, # 21. April 2008, 18:41:40
I believe ES4 is going to allow this trailing comma. (At least that's the impression people are giving me on es4-discuss...)
By liorean, # 25. April 2008, 12:57:19