Closed
Description
- Version: all supported versions (oldest tested branch is v4.x (4.8.0))
- Platform: all
- Subsystem: util
In the node
REPL, sparse elements of an array are shown as "empty":
> new Array(3)
[ , , ]
However, when one copy the resulting [ , , ]
and reenter it into the prompt, a different array is shown, thus confusing the developer:
> [ , , ]
[ , ]
How the Chrome inspector deals with this situation is explicitly make the inspected result not compliant JS:
> new Array(3)
[undefined × 3]
> [undefined, , undefined] // to differentiate between a hole and `undefined`
[undefined, undefined × 1, undefined]
Firefox is more upfront:
> new Array(3)
Array [ <3 empty slots> ]
> [undefined, , undefined] // to differentiate between a hole and `undefined`
Array [ undefined, <1 empty slot>, undefined ]