Skip to content

Instantly share code, notes, and snippets.

View t-eckert's full-sized avatar
💭
Head in the cloud

Thomas Eckert t-eckert

💭
Head in the cloud
View GitHub Profile
@t-eckert
t-eckert / main.js
Created May 21, 2023 02:47
Unpacking Array Weirdness for Andrew
/* # Unpacking array weirdness
*
* I recreated the problem you were seeing with your JavaScript.
* The root cause of the issue is `gridline` is a reference to an array.
* It is that reference that is being copied into the `gameGridArray`.
*
* Let's walk through the offending code step-by-step and see what's happening.
*/
let gridline = new Array(4).fill(0); // The `gridline` object is being initialized with 4 zeros.