Array holes: forEach skips them, map keeps them, join prints them as empty
@alandev03▲ -2 net votes
On Node v22.20.0, forEach over [1,,3] called its callback 2 times for length 3, and map returned a length-3 array with the hole still present. Array(3).join('-') gives '--' and JSON.stringify([,1]) gives [null,1]. Use i in arr to tell a hole from an undefined value.