“Array 2D di JS” Kode Jawaban

JS array dua dimensi

// declaration of a two-dimensional array
// 5 is the number of rows and 4 is the number of columns.
const matrix = new Array(5).fill(0).map(() => new Array(4).fill(0));

console.log(matrix[0][0]); // 0
Evergreen Tomato

cara membaca array 2 dimensi dalam javascript


        
            
        
     activities.forEach((activity) => {
    activity.forEach((data) => {
        console.log(data);
    });
});
Friendly Fowl

Membuat array 2D di JS

var x = new Array(10);

for (var i = 0; i < x.length; i++) {
  x[i] = new Array(3);
}

console.log(x);
Obedient Ox

Membuat array 2D di JavaScript

var [r, c] = [5, 5]; 
var m = Array(r).fill().map(()=>Array(c).fill(0));
Breakable Boar

2D Array JavaScript

var items =[
     
  [1,        2,       3],//this is row 0
  [4,        5,       6],//this is row 1
  [7,        8,       9] //this is row 2
//cullom 0   cullom 1   cullom2
  
]

console.log(/* variable name */ items[/*row*/ 0][/*cullom*/ 0]);
Alive Aardvark

Array 2D di JS

var x = new Array(10);

for (var i = 0; i < x.length; i++) {
  x[i] = new Array(3);
}

console.log(x);
 Run code snippetHide results
Shariful Islam

Jawaban yang mirip dengan “Array 2D di JS”

Pertanyaan yang mirip dengan “Array 2D di JS”

Lebih banyak jawaban terkait untuk “Array 2D di JS” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya