Hướng dẫn does javascript have multidimensional arrays? - javascript có mảng nhiều chiều không?

Mảng đa chiều không được cung cấp trực tiếp trong JavaScript. Nếu chúng ta muốn sử dụng bất cứ thứ gì hoạt động như một mảng đa chiều thì chúng ta cần tạo một mảng đa chiều bằng cách sử dụng một mảng một chiều khác. Vì vậy, các mảng đa chiều trong JavaScript được gọi là các mảng bên trong một mảng khác. Chúng ta cần đặt một số mảng bên trong một mảng, sau đó tổng số điều hoạt động giống như một mảng đa chiều. Mảng, trong đó các mảng khác sẽ chèn, mảng đó được sử dụng làm mảng đa chiều trong mã của chúng tôi. Để xác định một mảng đa chiều, nó giống hệt như xác định một mảng một chiều bình thường.

Mảng một chiều:

var arr = []; // Empty 1D array
var arr1 = ["A", "B", "C", "D"] // 1D array contains some alphabets
var arr1 = [1, 2, 3, 4, 5] // 1D array contains some digits

Mảng đa chiều đa chiều:

  • Phương pháp 1: ________ 1
    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 

    Ở đây ARR1, ARR2, ARR5 là một số mảng 1D bên trong mảng lương.

  • Phương pháp 2: ________ 2
    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];

    Ở đây, mảng tiền lương hoạt động giống như một mảng đa chiều. Ký hiệu này được gọi là nghĩa đen.

Truy cập phần tử của mảng tiền lương:

  • Để truy cập phần tử mảng, chúng tôi cần một ký hiệu dựa trên chỉ mục đơn giản
  • Đối với nhiều lần lặp, chúng ta cần sử dụng vòng lặp để truy cập các yếu tố, ________ 4

Thêm các phần tử trong mảng đa chiều: Thêm các phần tử vào các mảng đa chiều có thể đạt được theo hai cách trong mảng bên trong hoặc mảng bên ngoài. Mảng bên trong có thể được thực hiện theo hai cách khác nhau. Adding elements in multi-dimensional arrays can be achieved in two ways in inner array or outer array. The inner array can be done in two different ways.

  • Thêm các phần tử vào mảng bên trong:
    • Chúng ta có thể sử dụng ký hiệu khung vuông đơn giản để thêm các phần tử vào mảng đa chiều .________ 5
    • Chúng ta có thể sử dụng phương thức push () để thêm các phần tử vào mảng .________ 6push() method to add elements in the array.
      salary[3].push("India", "Mumbai");
      
      // It add "India" at the 4th index and "Mumbai" at
      // 5th index of 4th sub-array
      // If we print the entire 4th sub-array,
      // document.write(salary[3]);
      // The output will be :  ["EFG", 31, 28000, "India", "Mumbai"]
      // Indexing starts from 0
  • Thêm các phần tử vào mảng bên ngoài: Nó tương tự như các phương thức trước đó .________ 7 It is much similar to previous methods.
    salary.push(["MNO", 29, 33300]);
    // This row added after the last row in the "salary" array

Loại bỏ các phần tử trong mảng đa chiều: chúng ta có thể sử dụng các phương thức pop () để loại bỏ các phần tử khỏi phần bên trong và cũng sử dụng phương thức pop () để loại bỏ toàn bộ mảng bên trong. We can use pop() methods to remove elements from inner-arrays, and also use pop() method for removing a entire inner array.

// Remove last element from 4th sub-array
// That is 28000 indexing starts from 0
salary[3].pop(); 

// Removes last sub-array
// That is "["EFG", 31, 28000]"
salary.pop();
  • Ví dụ 1:

    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    5

    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    6
    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    7
    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    8
    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    9

    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    6
    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];
    1
    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];
    2223

    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    6
    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];
    5
    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];
    6
    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];
    7

    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    6
    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];
    9
    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];
    222

    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    6
    // This notation access the salary of "ABC" person which is 18000, 
    // [0] selects 1st row, and [2] selects the 3rd element
    // of that 1st row which is 18000
    salary[0][2];
    
    // Similarly, 
    salary[3][2]; // Selects 28000
    
    **This notation is used for both Method 1 and Method 2.
    
    3
    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];
    222

    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    6
    // This notation access the salary of "ABC" person which is 18000, 
    // [0] selects 1st row, and [2] selects the 3rd element
    // of that 1st row which is 18000
    salary[0][2];
    
    // Similarly, 
    salary[3][2]; // Selects 28000
    
    **This notation is used for both Method 1 and Method 2.
    
    7

    // This notation access the salary of "ABC" person which is 18000, 
    // [0] selects 1st row, and [2] selects the 3rd element
    // of that 1st row which is 18000
    salary[0][2];
    
    // Similarly, 
    salary[3][2]; // Selects 28000
    
    **This notation is used for both Method 1 and Method 2.
    
    8
    // This notation access the salary of "ABC" person which is 18000, 
    // [0] selects 1st row, and [2] selects the 3rd element
    // of that 1st row which is 18000
    salary[0][2];
    
    // Similarly, 
    salary[3][2]; // Selects 28000
    
    **This notation is used for both Method 1 and Method 2.
    
    9
    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    6
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    1

    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    2
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    3
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    4
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    5

    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    6

    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    7

    Output:

    ABC, 24, 18000
    EFG, 30, 30000
    IJK, 28, 41000
    EFG, 31, 28000
    EFG, 29, 35000
  • Ví dụ 2:

    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    5

    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    6
    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    0

    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    1
    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    2
    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    8
    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    4

    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    1
    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    2
    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];
    2
    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    8

    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    1
    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    2
    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];
    6
    salary[3].push("India", "Mumbai");
    
    // It add "India" at the 4th index and "Mumbai" at
    // 5th index of 4th sub-array
    // If we print the entire 4th sub-array,
    // document.write(salary[3]);
    // The output will be :  ["EFG", 31, 28000, "India", "Mumbai"]
    // Indexing starts from 0
    2

    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    1
    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    2
    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];
    2
    salary[3].push("India", "Mumbai");
    
    // It add "India" at the 4th index and "Mumbai" at
    // 5th index of 4th sub-array
    // If we print the entire 4th sub-array,
    // document.write(salary[3]);
    // The output will be :  ["EFG", 31, 28000, "India", "Mumbai"]
    // Indexing starts from 0
    6

    salary[3].push("India", "Mumbai");
    
    // It add "India" at the 4th index and "Mumbai" at
    // 5th index of 4th sub-array
    // If we print the entire 4th sub-array,
    // document.write(salary[3]);
    // The output will be :  ["EFG", 31, 28000, "India", "Mumbai"]
    // Indexing starts from 0
    7

    // This notation access the salary of "ABC" person which is 18000, 
    // [0] selects 1st row, and [2] selects the 3rd element
    // of that 1st row which is 18000
    salary[0][2];
    
    // Similarly, 
    salary[3][2]; // Selects 28000
    
    **This notation is used for both Method 1 and Method 2.
    
    8
    // This notation access the salary of "ABC" person which is 18000, 
    // [0] selects 1st row, and [2] selects the 3rd element
    // of that 1st row which is 18000
    salary[0][2];
    
    // Similarly, 
    salary[3][2]; // Selects 28000
    
    **This notation is used for both Method 1 and Method 2.
    
    9
    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    6
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    1

    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    2
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    3
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    4
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    5

    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    6

    salary.push(["MNO", 29, 33300]);
    // This row added after the last row in the "salary" array
    7

    Output:

    ABC, 24, 18000
    EFG, 30, 30000
    IJK, 28, 41000
    EFG, 31, 28000
    EFG, 29, 35000
  • Ví dụ 2:

    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    5

    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    6
    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    0

    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    1
    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    2
    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    8
    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    4

    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    1
    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    2
    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];
    2
    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    8

    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    1
    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    2
    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];
    6
    salary[3].push("India", "Mumbai");
    
    // It add "India" at the 4th index and "Mumbai" at
    // 5th index of 4th sub-array
    // If we print the entire 4th sub-array,
    // document.write(salary[3]);
    // The output will be :  ["EFG", 31, 28000, "India", "Mumbai"]
    // Indexing starts from 0
    2

    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    1
    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    2
    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];
    2
    salary[3].push("India", "Mumbai");
    
    // It add "India" at the 4th index and "Mumbai" at
    // 5th index of 4th sub-array
    // If we print the entire 4th sub-array,
    // document.write(salary[3]);
    // The output will be :  ["EFG", 31, 28000, "India", "Mumbai"]
    // Indexing starts from 0
    6

    salary[3].push("India", "Mumbai");
    
    // It add "India" at the 4th index and "Mumbai" at
    // 5th index of 4th sub-array
    // If we print the entire 4th sub-array,
    // document.write(salary[3]);
    // The output will be :  ["EFG", 31, 28000, "India", "Mumbai"]
    // Indexing starts from 0
    7

    Ví dụ 3:

    ABC, 24, 18000
    EFG, 30, 30000
    IJK, 28, 41000
    EFG, 31, 28000
    EFG, 29, 35000
    8
    ABC, 24, 18000
    EFG, 30, 30000
    IJK, 28, 41000
    EFG, 31, 28000
    EFG, 29, 35000
    9
    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    00
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    4
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    5

    salary.push(["MNO", 29, 33300]);
    // This row added after the last row in the "salary" array
    7

    Output:

    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    1
  • ABC, 24, 18000
    EFG, 30, 30000
    IJK, 28, 41000
    EFG, 31, 28000
    EFG, 29, 35000
    8
    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    04
    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    05
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    4
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    5

    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    5

    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    6
    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    0

    Ví dụ 3:

    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    1
    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    2
    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];
    2
    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    8

    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    1
    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    2
    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];
    6
    salary[3].push("India", "Mumbai");
    
    // It add "India" at the 4th index and "Mumbai" at
    // 5th index of 4th sub-array
    // If we print the entire 4th sub-array,
    // document.write(salary[3]);
    // The output will be :  ["EFG", 31, 28000, "India", "Mumbai"]
    // Indexing starts from 0
    2

    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    1
    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    2
    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];
    2
    salary[3].push("India", "Mumbai");
    
    // It add "India" at the 4th index and "Mumbai" at
    // 5th index of 4th sub-array
    // If we print the entire 4th sub-array,
    // document.write(salary[3]);
    // The output will be :  ["EFG", 31, 28000, "India", "Mumbai"]
    // Indexing starts from 0
    6

    salary[3].push("India", "Mumbai");
    
    // It add "India" at the 4th index and "Mumbai" at
    // 5th index of 4th sub-array
    // If we print the entire 4th sub-array,
    // document.write(salary[3]);
    // The output will be :  ["EFG", 31, 28000, "India", "Mumbai"]
    // Indexing starts from 0
    7

    ABC, 24, 18000
    EFG, 30, 30000
    IJK, 28, 41000
    EFG, 31, 28000
    EFG, 29, 35000
    8
    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    30
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    5

    // This notation access the salary of "ABC" person which is 18000, 
    // [0] selects 1st row, and [2] selects the 3rd element
    // of that 1st row which is 18000
    salary[0][2];
    
    // Similarly, 
    salary[3][2]; // Selects 28000
    
    **This notation is used for both Method 1 and Method 2.
    
    8
    // This notation access the salary of "ABC" person which is 18000, 
    // [0] selects 1st row, and [2] selects the 3rd element
    // of that 1st row which is 18000
    salary[0][2];
    
    // Similarly, 
    salary[3][2]; // Selects 28000
    
    **This notation is used for both Method 1 and Method 2.
    
    9
    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    6
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    1

    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    2
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    3
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    4
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    5

    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    6

    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    41
    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    42
    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    43

    ABC, 24, 18000
    EFG, 30, 30000
    IJK, 28, 41000
    EFG, 31, 28000
    EFG, 29, 35000
    8
    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    45
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    5

    // This notation access the salary of "ABC" person which is 18000, 
    // [0] selects 1st row, and [2] selects the 3rd element
    // of that 1st row which is 18000
    salary[0][2];
    
    // Similarly, 
    salary[3][2]; // Selects 28000
    
    **This notation is used for both Method 1 and Method 2.
    
    8
    // This notation access the salary of "ABC" person which is 18000, 
    // [0] selects 1st row, and [2] selects the 3rd element
    // of that 1st row which is 18000
    salary[0][2];
    
    // Similarly, 
    salary[3][2]; // Selects 28000
    
    **This notation is used for both Method 1 and Method 2.
    
    9
    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    6
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    1

    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    2
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    3
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    4
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    5

    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    6

    ABC, 24, 18000
    EFG, 30, 30000
    IJK, 28, 41000
    EFG, 31, 28000
    EFG, 29, 35000
    8
    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    57

    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    58
    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    59
    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    60
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    5

    Ví dụ 2:

    // This notation access the salary of "ABC" person which is 18000, 
    // [0] selects 1st row, and [2] selects the 3rd element
    // of that 1st row which is 18000
    salary[0][2];
    
    // Similarly, 
    salary[3][2]; // Selects 28000
    
    **This notation is used for both Method 1 and Method 2.
    
    8
    // This notation access the salary of "ABC" person which is 18000, 
    // [0] selects 1st row, and [2] selects the 3rd element
    // of that 1st row which is 18000
    salary[0][2];
    
    // Similarly, 
    salary[3][2]; // Selects 28000
    
    **This notation is used for both Method 1 and Method 2.
    
    9
    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    6
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    1

    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    2
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    3
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    4
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    5

    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    6

    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    76

    Output:

    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    2
  • Ví dụ 2:

    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    5

    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    6
    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    0

    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    1
    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    2
    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    8
    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    4

    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    1
    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    2
    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];
    2
    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    8

    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    1
    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    2
    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];
    6
    salary[3].push("India", "Mumbai");
    
    // It add "India" at the 4th index and "Mumbai" at
    // 5th index of 4th sub-array
    // If we print the entire 4th sub-array,
    // document.write(salary[3]);
    // The output will be :  ["EFG", 31, 28000, "India", "Mumbai"]
    // Indexing starts from 0
    2

    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    1
    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    2
    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];
    2
    salary[3].push("India", "Mumbai");
    
    // It add "India" at the 4th index and "Mumbai" at
    // 5th index of 4th sub-array
    // If we print the entire 4th sub-array,
    // document.write(salary[3]);
    // The output will be :  ["EFG", 31, 28000, "India", "Mumbai"]
    // Indexing starts from 0
    6

    salary[3].push("India", "Mumbai");
    
    // It add "India" at the 4th index and "Mumbai" at
    // 5th index of 4th sub-array
    // If we print the entire 4th sub-array,
    // document.write(salary[3]);
    // The output will be :  ["EFG", 31, 28000, "India", "Mumbai"]
    // Indexing starts from 0
    7

    ABC, 24, 18000
    EFG, 30, 30000
    IJK, 28, 41000
    EFG, 31, 28000
    EFG, 29, 35000
    8
    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    30
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    5

    // This notation access the salary of "ABC" person which is 18000, 
    // [0] selects 1st row, and [2] selects the 3rd element
    // of that 1st row which is 18000
    salary[0][2];
    
    // Similarly, 
    salary[3][2]; // Selects 28000
    
    **This notation is used for both Method 1 and Method 2.
    
    8
    // This notation access the salary of "ABC" person which is 18000, 
    // [0] selects 1st row, and [2] selects the 3rd element
    // of that 1st row which is 18000
    salary[0][2];
    
    // Similarly, 
    salary[3][2]; // Selects 28000
    
    **This notation is used for both Method 1 and Method 2.
    
    9
    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    6
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    1

    Ví dụ 2:

    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    6

    ABC, 24, 18000
    EFG, 30, 30000
    IJK, 28, 41000
    EFG, 31, 28000
    EFG, 29, 35000
    8
    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];
    10
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    5

    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];
    12
    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];
    13
    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];
    14

    // This notation access the salary of "ABC" person which is 18000, 
    // [0] selects 1st row, and [2] selects the 3rd element
    // of that 1st row which is 18000
    salary[0][2];
    
    // Similarly, 
    salary[3][2]; // Selects 28000
    
    **This notation is used for both Method 1 and Method 2.
    
    8
    // This notation access the salary of "ABC" person which is 18000, 
    // [0] selects 1st row, and [2] selects the 3rd element
    // of that 1st row which is 18000
    salary[0][2];
    
    // Similarly, 
    salary[3][2]; // Selects 28000
    
    **This notation is used for both Method 1 and Method 2.
    
    9
    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    6
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    1

    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    2
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    3
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    4
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    5

    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    6

    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    76

    Output:

    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    3
  • Ví dụ 2:

    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    5

    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    6
    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    0

    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    1
    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    2
    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    8
    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    4

    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    1
    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    2
    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];
    2
    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    8

    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    1
    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    2
    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];
    6
    salary[3].push("India", "Mumbai");
    
    // It add "India" at the 4th index and "Mumbai" at
    // 5th index of 4th sub-array
    // If we print the entire 4th sub-array,
    // document.write(salary[3]);
    // The output will be :  ["EFG", 31, 28000, "India", "Mumbai"]
    // Indexing starts from 0
    2

    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    1
    salary[3][3] = "India";
    
    // It adds "India" at the 4th index of 4th sub-array,
    // If we print the entire 4th sub-array, document.write(salary[3]);
    // the output will be :  ["EFG", 31, 28000, "India"]
    // indexing starts from 0
    2
    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];
    2
    salary[3].push("India", "Mumbai");
    
    // It add "India" at the 4th index and "Mumbai" at
    // 5th index of 4th sub-array
    // If we print the entire 4th sub-array,
    // document.write(salary[3]);
    // The output will be :  ["EFG", 31, 28000, "India", "Mumbai"]
    // Indexing starts from 0
    6

    salary[3].push("India", "Mumbai");
    
    // It add "India" at the 4th index and "Mumbai" at
    // 5th index of 4th sub-array
    // If we print the entire 4th sub-array,
    // document.write(salary[3]);
    // The output will be :  ["EFG", 31, 28000, "India", "Mumbai"]
    // Indexing starts from 0
    7

    ABC, 24, 18000
    EFG, 30, 30000
    IJK, 28, 41000
    EFG, 31, 28000
    EFG, 29, 35000
    8
    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    30
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    5

    // This notation access the salary of "ABC" person which is 18000, 
    // [0] selects 1st row, and [2] selects the 3rd element
    // of that 1st row which is 18000
    salary[0][2];
    
    // Similarly, 
    salary[3][2]; // Selects 28000
    
    **This notation is used for both Method 1 and Method 2.
    
    8
    // This notation access the salary of "ABC" person which is 18000, 
    // [0] selects 1st row, and [2] selects the 3rd element
    // of that 1st row which is 18000
    salary[0][2];
    
    // Similarly, 
    salary[3][2]; // Selects 28000
    
    **This notation is used for both Method 1 and Method 2.
    
    9
    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    6
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    1

    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    2
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    3
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    4
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    5

    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    6

    ABC, 24, 18000
    EFG, 30, 30000
    IJK, 28, 41000
    EFG, 31, 28000
    EFG, 29, 35000
    8
    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];
    58 

    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];
    59
    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    59
    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];
    61
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    5

    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];
    63

    // This notation access the salary of "ABC" person which is 18000, 
    // [0] selects 1st row, and [2] selects the 3rd element
    // of that 1st row which is 18000
    salary[0][2];
    
    // Similarly, 
    salary[3][2]; // Selects 28000
    
    **This notation is used for both Method 1 and Method 2.
    
    8
    // This notation access the salary of "ABC" person which is 18000, 
    // [0] selects 1st row, and [2] selects the 3rd element
    // of that 1st row which is 18000
    salary[0][2];
    
    // Similarly, 
    salary[3][2]; // Selects 28000
    
    **This notation is used for both Method 1 and Method 2.
    
    9
    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    6
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    1

    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    2
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    3
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    4
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    5

    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    6

    ABC, 24, 18000
    EFG, 30, 30000
    IJK, 28, 41000
    EFG, 31, 28000
    EFG, 29, 35000
    8
    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];
    74
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    5

    var salary = [
       ["ABC", 24, 18000],
       ["EFG", 30, 30000],
       ["IJK", 28, 41000],
       ["EFG", 31, 28000],
    ];
    76

    // This notation access the salary of "ABC" person which is 18000, 
    // [0] selects 1st row, and [2] selects the 3rd element
    // of that 1st row which is 18000
    salary[0][2];
    
    // Similarly, 
    salary[3][2]; // Selects 28000
    
    **This notation is used for both Method 1 and Method 2.
    
    8
    // This notation access the salary of "ABC" person which is 18000, 
    // [0] selects 1st row, and [2] selects the 3rd element
    // of that 1st row which is 18000
    salary[0][2];
    
    // Similarly, 
    salary[3][2]; // Selects 28000
    
    **This notation is used for both Method 1 and Method 2.
    
    9
    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    6
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    1

    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    2
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    3
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    4
    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    5

    // This loop is for outer array
    for (var i = 0, l1 = salary.length; i < l1; i++) {
    
        // This loop is for inner-arrays
        for (var j = 0, l2 = salary[i].length; j < l2; j++) {
    
            // Accessing each elements of inner-array
            documents.write( salary[i][j] ); 
        }
    }
    6

    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    76

    Output:

    1st, need to define some 1D array
    var arr1 = ["ABC", 24, 18000];
    var arr2 = ["EFG", 30, 30000];
    var arr3 = ["IJK", 28, 41000];
    var arr4 = ["EFG", 31, 28000];
    var arr5 = ["EFG", 29, 35000];
    // "salary" defines like a 1D array but it already contains some 1D array
    var salary = [arr1, arr2, arr3, arr4, arr5]; 
    4

JavaScript được biết đến nhiều nhất để phát triển trang web nhưng nó cũng được sử dụng trong nhiều môi trường không phải là trình duyệt. Bạn có thể tìm hiểu JavaScript từ cơ sở bằng cách làm theo các ví dụ JavaScript và JavaScript này.


Mảng đa chiều hoạt động như thế nào trong JavaScript?

Dưới đây là cách bạn có thể tạo các mảng đa chiều trong JavaScript. Hãy để Student1 = ['Jack', 24]; Đặt sinh viên2 = ['Sara', 23]; Đặt sinh viên3 = ['Peter', 24]; // mảng đa chiều cho sinh viênData = [student1, student2, student3];let student1 = ['Jack', 24]; let student2 = ['Sara', 23]; let student3 = ['Peter', 24]; // multidimensional array let studentsData = [student1, student2, student3];

Mảng 2D trong JavaScript là gì?

Mảng hai chiều là một tập hợp các mục có chung một tên và chúng được tổ chức như một ma trận dưới dạng các hàng và cột.Mảng hai chiều là một mảng mảng, vì vậy chúng tôi tạo ra một mảng các đối tượng mảng một chiều.a collection of items which share a common name and they are organized as a matrix in the form of rows and columns. The two-dimensional array is an array of arrays, so we create an array of one-dimensional array objects.

Các mảng JavaScript có thể có các loại hỗn hợp không?

Như đã đề cập trước đó, JavaScript hỗ trợ các mảng hỗn hợp.Điều đó có nghĩa là bạn có thể tạo một mảng với số và chuỗi hoặc các đối tượng khác.JavaScript supports mixed arrays. That means you can create an array with numbers and strings or other objects.

Có mảng trong JavaScript không?

Các mảng JavaScript không được chỉ số bằng không: phần tử đầu tiên của một mảng là tại INDEX 0, phần thứ hai là tại INDEX 1, v.v.-và phần tử cuối cùng là ở giá trị của thuộc tính độ dài của mảng trừ 1.Các hoạt động sao chép mảng JavaScript tạo các bản sao nông.: the first element of an array is at index 0 , the second is at index 1 , and so on — and the last element is at the value of the array's length property minus 1 . JavaScript array-copy operations create shallow copies.