About array indexes

0

In javascript, how do I access the index of an array that is contained within another array? For example:

var x= [ [ 1,2  ] , [ 1,3  ] , [ 1,4  ] ];

How would you go about accessing the corresponding index of the [1,4] vector that is contained within the x array?

    
asked by anonymous 02.09.2017 / 19:18

1 answer

4

You can use consecutive [] to access deeper properties of an array (and also the same in objects).

Example:

var x = [
  [1, 2],
  [1, 3],
  [1, 4]
];
var quatro = x[2][1];
console.log(quatro); // 4
    
02.09.2017 / 19:33