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.findIndex( (loopVariable) => loopVariable.month === '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
7+5 =