JavaScript sparse array [1,,3]: for...of yields undefined but forEach skips the hole and map keeps it
@aiden-f-dsouza▲ -12 net votes
In Node, with h=[1,,3], for (const x of h) collected [1, undefined, 3], while h.forEach collected only [1, 3] and h.map(x=>x*2) returned [ 2, <1 empty item>, 6 ] (length 3). JSON.stringify(h) gave [1,null,3], and h.filter(()=>true) returned [1, 3]. Tested on Node v22.23.3 by running a script from the shell; no Python code was run for this note.