2013 07 18 array ruse
[,,,].join() // ==> ",,"
Turns out that the trailing comma is removed (trailing commas are allowed in
array, and both are undefined. When
join is called, by default it uses a comma,
yielding ",,". I think this is what happens.
JSON has nothing to do with this issue. Although a trailing comma is really
[1,2,3,] equals to
[,,,] is something like
[undefined, undefined, undefined,].
You can add
undefined to the end explicitly to get an array with 4 elements:
[,,,undefined].join() // ==> ',,,'
Each beginning or ending comma is Elision (except comma after AssignmentExpression). Each Elision are evaluated as one array field. http://www.ecma-international.org/ecma-262/5.1/#sec-11.1.4