I have a 2D array which looks like this:
2D array
var numbers=[[1,2,3,4,5],[6,2,3,5,5],[9,8,3,4,9]]
How to find the index value of the above two dimensional array?
Try like this
var searchItem=2; numbers.forEach(function(parentItem,parentIndex){ parentItem.forEach(function(childItem,childIndex){ if(childItem===searchItem){ console.log(parentIndex); console.log(childIndex); } }) });
1.4m articles
1.4m replys
5 comments
57.0k users