Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Array.fill does shallow filling #110

@sanjarcode

Description

@sanjarcode
$ node
Welcome to Node.js v18.16.1.
Type ".help" for more information.
> x = Array(2).fill(Array(2).fill(0))
[ [ 0, 0 ], [ 0, 0 ] ]
> x[0][0] = 3
3
> x
[ [ 3, 0 ], [ 3, 0 ] ]
> // wtf ;(
undefined
> x = new Array(2).fill(new Array(2).fill(0))
[ [ 0, 0 ], [ 0, 0 ] ]
> x[0][0] = 3
> x
[ [ 3, 0 ], [ 3, 0 ] ]
>

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions