Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

find the index of an object in an array

const letters = [{letter: 'a'},{letter: 'b'},{letter: 'c'}]

const index = letters.findIndex((element, index) => {
  if (element.letter === 'b') {
    return true
  }
})

//index is `1`
 
PREVIOUS NEXT
Tagged: #find #index #object #array
ADD COMMENT
Topic
Name
5+8 =