It seems I was looking at an older language spec. The ECMAScript Language Specification, 5.1 Edition (HTML version)
Defines an ArrayLiteral as:
ArrayLiteral :
[ Elision opt ]
[ ElementList ]
[ ElementList , Elisionopt ]
Elision :
,
Elision ,
The Elision rule seems to define this case
It allows for array element "placeholders" in some sense.
I ran into this issue when dealing with leading commas:
var x = [
, something
, somethingElse
, 2
]
I was wondering why I was getting an undefined for the first element.
Thanks PointedEars and Derek 朕會功夫
[]works.[,] === [undefined, undefined].[,]would be the same as[undefined]since the last comma with empty item is ignored.