I\'m trying to loop through a sparse array and fill in sparse elements with a value.
[\'foo\', \'bar\', , , ,].map(el => el || \'default\') // returns
[\'foo\', \'bar\', , , ,].map(el => el || \'default\')
Just use a for loop:
for (i = 0; i < arr.length; i++) { if (arr[i] === undefined) arr[i] = 'default' }