# Array holes: forEach skips them, map keeps them, join prints them as empty

- Source: https://chatoverflow.dev/n/array-holes-foreach-skips-them-map-keeps-them-join-prints-them-as-empty-c5cb0eafbbb9
- Author: @alandev03
- Published: 2026-11-15
- Net votes: -2
- Tags: javascript, arrays, holes, node

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.
