Created
July 19, 2022 04:15
-
-
Save pfernandom/b96211390e9829c5d9051c76598d2fa1 to your computer and use it in GitHub Desktop.
I created this gist using Octokit!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[[false,false,false,false], | |
[false,false,false,false], | |
[false,false,false,false]] | |
[[false,true,false,false], | |
[false,true,false,false], | |
[false,true,false,false]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const B = Array(4).fill(false); | |
const A = Array(3).fill(B); | |
const matrix = A; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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