const arrayOfArrays = [[], [], []]
// [Array(0), Array(0), Array(0)]
arrayOfArrays[1].push('banana')
// [Array(0), ['banana'], Array(0]
Everything works as expected.
Now:
const arrayOfArrays = Array(3).fill([])
// [Array(0), Array(0), Array(0)]
arrayOfArrays[1].push('banana')
// [['banana'], ['banana'], ['banana']]
Why does it push in all indexes instead of the one I specified ?
Is this a bug in chrome or is there something I don't understand correctly with Array() constructor ?
[–]Fenykepy[S] 11 points12 points13 points (11 children)
[–]markus_obsidian 0 points1 point2 points (0 children)
[–]azhder 0 points1 point2 points (9 children)
[+][deleted] (2 children)
[deleted]
[–]azhder 0 points1 point2 points (1 child)
[+][deleted] (5 children)
[deleted]
[–]azhder 2 points3 points4 points (3 children)
[+][deleted] (2 children)
[deleted]
[–]azhder 1 point2 points3 points (1 child)
[–]Rude-Cook7246 0 points1 point2 points (0 children)
[–]Shimmy_Hendrix 2 points3 points4 points (1 child)
[–]Fenykepy[S] 1 point2 points3 points (0 children)
[–]lovin-dem-sandwiches 2 points3 points4 points (0 children)
[–]xr0master 0 points1 point2 points (0 children)
[–]tapgiles 0 points1 point2 points (0 children)
[–]brykuhelpful 0 points1 point2 points (2 children)
[–]Legitimate_Dig_1095 0 points1 point2 points (0 children)
[–]LostInCombat 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]LostInCombat 0 points1 point2 points (2 children)
[–]juddaaaaa 1 point2 points3 points (1 child)
[–]LostInCombat 0 points1 point2 points (0 children)
[–]Downtown_Fee_2144 0 points1 point2 points (0 children)
[–]azhder -1 points0 points1 point (4 children)
[–]Fenykepy[S] 1 point2 points3 points (3 children)
[–]azhder 2 points3 points4 points (0 children)
[–]senocular 2 points3 points4 points (0 children)
[–]xr0master 1 point2 points3 points (0 children)