Multidimensional array example javascript

Updated at 01-Oct-2021, By samar

Multidimensional array example javascript

We will use programming in this lesson to attempt to solve the "Multidimensional array example javascript".

Multidimensional array is a type of array which store array values one or more than one level dipper in array object. Here we have code snippet for multidimensional javascript array example
  • Define multidimensional array and access value in javascript

    <script>
    let activities = [
        ['Work', 9],
        ['Eat', 1],
        ['Commute', 2],
        ['Play Game', 1],
        ['Sleep', 7]
    ];
    
    console.log(activities[0][0]);
    console.log(activities[0][1]);
    console.log(activities[1][0]);
    console.log(activities[1][1]);
    </script>
    

    Output:

    Work 
    9
    Eat
    1

    You can create an array in javascript usign [] brackets with comma separated values. You can access these values by passing the index of array value with [] notation.

Back to code snippet queries related javascript