Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6971015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:47:03+00:00 2026-05-27T16:47:03+00:00

I need to get the index of the json object in an array whose

  • 0

I need to get the index of the json object in an array whose by the objects id

here is the example code

var list = [ { _id: '4dd822c5e8a6c42aa70000ad',
    metadata: 
     { album: 'American IV: Man Comes Around',
       song: 'Hurt',
       coverart: 'http://images.mndigital.com/albums/044/585/435/m.jpeg',
       artist: 'Johnny Cash',
       length: 216,
       mnid: '44585439' } },
  { _id: '4dd80b16e8a6c428a900007d',
    metadata: 
     { album: 'OK Computer (Collector\'s Edition)',
       song: 'Paranoid Android',
       coverart: 'http://images.mndigital.com/albums/026/832/735/m.jpeg',
       artist: 'Radiohead',
       length: 383,
       mnid: '26832739' } },
  { _id: '4dd68694e8a6c42c80000479',
    metadata: 
     { album: 'The Presidents Of The United States Of America: Ten Year Super Bonus Special Anniversary Edition',
       song: 'Lump',
       coverart: 'http://images.mndigital.com/albums/011/698/433/m.jpeg',
       artist: 'The Presidents Of The United States Of America',
       length: 134,
       mnid: '11698479' } }
]

then pseudo code

 var index_of  = list.indexOf("4dd80b16e8a6c428a900007d");

obviously that is not gonna work but I wonder if there is anyway to do this without looping to find the index ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:47:04+00:00Added an answer on May 27, 2026 at 4:47 pm
    var i = list.length;
    while( i-- ) {
        if( list[i]._id === '4dd80b16e8a6c428a900007d' ) break;
    }
    
    alert(i);  // will be -1 if no match was found
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to get checked RadioButton Index using jQuery? I need to read it and
I need to perform a HTTP GET from PHP. More specifically, from within /index.php
I need get all items these have no categories int? categoryId = null; var
I have a array in javascript and i need to get it to my
I need to get the index of a exchange like NASDAQ rather than the
How emulate xmlhttprequest and get json response? Here Answer: HTTP/1.1 200 OK Server: nginx/1.1.7
How do I get the key value in a JSON object and the length
Just need get some vals located in application.ini(main ini) in the Controller plugin I
I'm working with C#.net developing applications for windows mobile 6, and i need get
I have two tables with a weak relation. I need get a text value

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.