Skip to content

Instantly share code, notes, and snippets.

@pfernandom
Created July 19, 2022 04:15
Show Gist options
  • Save pfernandom/b96211390e9829c5d9051c76598d2fa1 to your computer and use it in GitHub Desktop.
Save pfernandom/b96211390e9829c5d9051c76598d2fa1 to your computer and use it in GitHub Desktop.
I created this gist using Octokit!
// Initialize a 3x4 matrix with "false" values.
const matrix = Array(3).fill(Array(4).fill(false));
// some stringify to capture the actual values at this point of the execution
console.log(JSON.stringify(matrix));
// set middle value to true
matrix[1][1] = true;
console.log(JSON.stringify(matrix));
[[false,false,false,false],
[false,false,false,false],
[false,false,false,false]]
[[false,true,false,false],
[false,true,false,false],
[false,true,false,false]]
const B = Array(4).fill(false);
const A = Array(3).fill(B);
const matrix = A;
const matrix = Array(3).fill().map(el => Array(4).fill(false));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment