Home > database >  How to find the index of array?
How to find the index of array?

Time:11-21

I am trying to find the index of array but i cant. Can you help me?

var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], [13,14]]; I want to find 13 but I don't know what is index of it. I have tried to do var myData = myArray[3][0][0] but output is 'undefined'. How to find the target index?

CodePudding user response:

use myArray[3][1][0]

var myArray = [
  [1, 2, 3],
  [4, 5, 6],
  [7, 8, 9],
  [
    [10, 11, 12],
    [13, 14]
  ]
];
var myNum = myArray[3][1][0];
console.log(myNum);

CodePudding user response:

var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13,14]];

myArray[3][1]
// OUTPUT
// 13
  • Related