Search from array of objects in javascript




Search from array of objects in javascript

Link to my programming Video Library:
https://courses.LearnCodeOnline.in

Desktop: https://amzn.to/2GZ0C46
Laptop that I use: https://amzn.to/2Goui9Q
Wallpaper: https://imgur.com/a/FYHfk

Facebook: https://www.facebook.com/HiteshChoudharyPage
homepage: http://www.hiteshChoudhary.com
Download LearnCodeOnline.in app from Google play store and Apple App store

Disclaimer:
It doesn’t feel good to have a disclaimer in every video but this is how the world is right now.
All videos are for educational purpose and use them wisely. Any video may have a slight mistake, please take decisions based on your research. This video is not forcing anything on you.

All Amazon links are affiliate links (If any).

Original source


29 responses to “Search from array of objects in javascript”

  1. const index = newTodos.findIndex(function (todo, index) {

    console.log(todo);

    return todo.title === 'Go to Gym';

    })

    return todo.title === 'Go to Gym'
    I understood that it compares title and if title matches it returns true, but here index is returned how?
    It should return true, findIndex finds the index and if the condition matches, it will return, am i correct?

  2. Rather thank typing the entire code in 1 line, you should actually try and break down the way you write your code as well. Writing your entire code in 1 line makes it a bit tough for people. Anyway, thanks! 😉

  3. Hey. Can you explain me the necessity or significance of using === in return statement of findIndex method. Here, we are comparing the object title with a string right? so how is it same as comparing or checking if they belong to the same memory space?
    p.s. i have seen your ==v/s=== video but i don't understand how === is returning true value when an object title is compared with a string.

  4. why the hell do you mix the (to lower case) problem with finding object in the array. this makes lot of confusion for new learners. just put it aside.

  5. Hello bro, Thank you for the lesson. I have a confusion in the method 1 : const index = myToDos.findIndex(function(todo, index)).
    My question is, how does the todo and index get values? because we are not calling in the function with any parameters. I understand it is a self invoking function but couldnt understand how the parameters got their value. any help would be appreciated. thanks in advance.

Leave a Reply