article

lookup the index of an object

[WHAT]

  1. ] a javascript function to find any object in an array of objects, using any element in the

[WHY]

  1. ] lookup the index of a particular element in an array of javascript objects

[WHERE]

  1. ] READ THE FULL ARTICLE
    1. ] http://debugmode.net/2013/02/19/how-to-find-index-of-an-item-in-javascript-object-array/ 
  2. ]

[WHEN]

  1. ] project-4800-pass - IN routes/index - selections

[EXAMPLE]

  1. ]

[HOW-TO]

  1. ] define function
  2.  function findIndexByKeyValue(searchDrivers, key, valuetosearch) {
            for (var i = 0; i < searchDrivers.length; i++) {
                if (searchDrivers[i][key] == valuetosearch) {
                    return i;
                }
            }
            return "not found";
        }
  3. ] call function
    1. var driverIndex = findIndexByKeyValue(drivers,"id","48");
      

[REFERENCE]

  1. ] js indexOf arrary,
  2. ] js indexOf string

 

Details Photos Edit more

Details

ID: 4562

NAME: lookup-index-of-object-in-array-of-objects

DESCRIPTION: by Dhananjay Kumar - How to find index of an item in JavaScript Object Array - a simple function that will return the index of any object in an any given array of object, given the "key" and the "value" to match

AUTHOR: article.author/s

EDITOR: article.editor/s

PUBLISHER: article.publisher/s

STATUS: Write

PRIORITY: 0

OWNER ID: 75

Content Photos Edit more

photos

page_photo

actions

Email Email-Owner SMS and