Over array indexes

Asked

Viewed 20 times

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 access the corresponding vector index [1,4] which is contained within the array x?

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.