]> git.cworth.org Git - lmno.games/commitdiff
Use an array spread syntax instead of .fill(null)
authorCarl Worth <cworth@cworth.org>
Sat, 20 Jun 2020 17:21:32 +0000 (10:21 -0700)
committerCarl Worth <cworth@cworth.org>
Sat, 20 Jun 2020 17:21:32 +0000 (10:21 -0700)
I don't really need null items. In fact, the copy here with the appray
spread syntax gives undefined, not null items. All I need is items
that map() will actually act on. The initial Array(9) gives only
"empty" items which map() ignores.

scribe/scribe.jsx

index be0de3799acf1f6bedaeb2171de86e9588832c38..78155949f782174a6ff40d2a80c7b5948f715868 100644 (file)
@@ -268,7 +268,7 @@ class Game extends React.Component {
       game_info: {},
       player_info: {},
       other_players: [],
-      squares: Array(9).fill(null).map(() => Array(9).fill(null)),
+      squares: [...Array(9)].map(() => Array(9).fill(null)),
       moves: 0,
       next_to_play: "+"
     };