Javascript examples for Array Operation:Array Search
Searching for first index in an array of arrays with Javascript
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*from www .j a v a 2 s.c o m*/ var arr = [['ID 1', 122.123], ['ID 2', 123.33], ['ID 3', 103.32]]; function find( data, term ){ ret = null; data.forEach(function(item, index){ if (item[0] === term) ret = index; }); return ret; }; console.log(find( arr, 'Account 2')); } </script> </head> <body> </body> </html>