# no-sparse-arrays

Disallow sparse arrays.

Sparse arrays are arrays with empty slots, they are denoted by extra commas, such as:

let foo = [,,];
let foo = [bar,, baz];

Sparse elements will be filled in as undefined elements and count towards array length. This is often a typo or is hard to comprehend and an explicit method should be used.

# Invalid Code Examples

let foo = [,];
let bar = [foo,, bar];
More incorrect examples
[,]
[...2,, 3]
[4,,]
More correct examples
[1, 2]
[3,]

Source (opens new window)

Last Updated: 11/18/2020, 9:36:33 PM