Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Get the index of an Object in an Array in JavaScript

const Season = [
  {
    month:'January',
    season: 'Winter',
  },
  {
    month:'March',
    season: 'Spring',
  },
  {
    month:'June',
    season: 'Summer',
  },
  {
    month:'August',
    season: 'Autumn',
  },
]

const index = Season.map( (loopVariable) => loopVariable.month).indexOf
 ("March"));
console.log("The index of March Month is",index)
Source by itsjavascript.com #
 
PREVIOUS NEXT
Tagged: #Get #index #Object #Array #JavaScript
ADD COMMENT
Topic
Name
4+9 =