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", undefined × 3]
How would I return ["foo", "bar", "default", "default", "default", "default"]
mapcalls a provided callback function once for each element in an array, in order, and constructs a new array from the results. callback is invoked only for indexes of the array which have assigned values; it is not invoked for indexes which have been deleted or which have never been assigned values."map()still has those positions.