Search from array of objects in javascript

Поделиться
HTML-код
  • Опубликовано: 11 сен 2024

Комментарии • 128

  • @mananpatel9802
    @mananpatel9802 4 года назад +3

    it may sound a bit complex but u taught so well that i wasn't confuse at any point in the video, your explanations are so clear, probably you are one of the best programming teacher on RUclips :)

  • @nusrathfatima7095
    @nusrathfatima7095 5 лет назад +10

    Please make short videos..its difficult to understand this concept but I'm learning so many things from you. I appreciate your effort. Thank You @Hitesh Choudhary❤️❤️

  • @gravelessForever
    @gravelessForever 4 года назад +1

    To anyone that is confused about findIndex:
    findIndex is a method that will iterate through each item in the array.
    The "callback" function he adds into it, is a "test"
    findIndex will iterate through each item in the array, and run it through this "test"
    First it passes the item into the "test" as an argument, in the case of 9:10, the arg is "todo"
    Your "test" should be set up so that it will return true or false based on this item of the array that is being tested.
    If it returns true (or false I forget), the method findIndex will return the index of the array that passed your "test".

  • @pottingshedgene
    @pottingshedgene 4 года назад

    Finally, someone who explains that parameter/argument/variable names could be just made up. Thank you Hitesh.

  • @keshavsharma3101
    @keshavsharma3101 4 года назад

    Yes Sir you are right it is hard to teach , talk and write a code but i want to say sir you have done a fabulous job.I want to thank you from my bottom of my heart. I always find it hard to study javascript but your well structured course help me to get it. THANK-YOU SIR

  • @kaituo1803
    @kaituo1803 6 лет назад +23

    I like your videos a lot, but not this one. I found this one is not as clearly-taught as your previous videos.

  • @sanudajayathilaka3173
    @sanudajayathilaka3173 5 лет назад +1

    go through all the documentaion for the findIndex() all of your confusions will be solved trust me!!! video is amazing thank u soo much

    • @mystique1127
      @mystique1127 4 года назад

      Ok. I am going for it. If i am confused afterwards, u r ded 😪

  • @dilipgautam
    @dilipgautam 6 лет назад +4

    Enjoying the series,sir. If possible make video about machine learning with javascript and how to get started.

  • @mocococo2877
    @mocococo2877 3 года назад

    Thank you for your time and efforts to make this video.
    One thing I was waiting for you to say explicitly was if those return just one value or more than one, if we have duplicate values in an array.

  • @dennypaul
    @dennypaul 5 лет назад +10

    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.

    • @vivekbhardwaj8295
      @vivekbhardwaj8295 4 года назад

      understand it as forEach

    • @sucesssoulman
      @sucesssoulman 4 года назад +1

      A callback function in a findIndex() works like that. You can use even 4 parameters and each one has its own objective. the first parameter: element
      The current element being processed in the array.
      the second parameter: index which is Optional
      The index of the current element being processed in the array.
      array Optional
      the third parameter: The array findIndex() was called upon.
      this parameter is Optional

  • @tim.bogdanov
    @tim.bogdanov 4 года назад +1

    why are you setting all your functions inside a variable?

  • @mohitnayak5049
    @mohitnayak5049 5 лет назад +6

    This video is confusing. I'm confused a bit. Previous videos are much more clear. Help.

  • @mfklogsaif
    @mfklogsaif 5 лет назад +2

    Amazing style of teaching you have, really impressed!

  • @poojaanandan3869
    @poojaanandan3869 5 лет назад +1

    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.

  • @sachintiwari5871
    @sachintiwari5871 6 лет назад +1

    Great explanation in very easy way sir......

  • @yashshende2786
    @yashshende2786 6 лет назад +9

    Sir I watch video 5 to 6 time still I am little bit confused what should I do

  • @yugankumar6416
    @yugankumar6416 5 лет назад +7

    Tip 1 : "Keep Moving" 😂♥️

  • @dragonboosterartha
    @dragonboosterartha 2 года назад

    Awesome! Thank you for your tuition. It's very useful for me.🤝

  • @shubhiVerma_
    @shubhiVerma_ 5 лет назад

    video is Awsom and guys how have confusion in that , they read documentation things gets more clear !!!!

  • @mukeshphulwani5972
    @mukeshphulwani5972 6 лет назад +34

    This things can be done much more easily you are going little complex here

    • @niharranjanbhuyan9839
      @niharranjanbhuyan9839 6 лет назад +2

      Yeah

    • @songlee8456
      @songlee8456 6 лет назад +3

      How can it be more simple? He just not confortable in what he's teaching, other than that this is the best approach to find an element inside an array of objects. Index of is not a good option

    • @tanujkalra7334
      @tanujkalra7334 4 года назад +1

      @@songlee8456 function search(arrayofobjects,index) {

      for (var i = arrayofobjects.length - 1; i >= 0; i--) {
      if(arrayofobjects[i].name.toLowerCase()===index.toLowerCase()) return i;
      }
      return -1;
      }

  • @rahulagnihotri344
    @rahulagnihotri344 4 года назад +7

    Incredibly confusing video, after watching 3 times also I understood nothing, really very complex.

  • @3101leonardo
    @3101leonardo 2 года назад

    Dude you are the best.

  • @girishadapa90
    @girishadapa90 6 лет назад

    Really no words hithesh bro ... Definitely some people's learn & earn your videos via ... Nyc nyc

  • @GorillaDev417
    @GorillaDev417 3 года назад

    Love your teaching style! Thanks!

  • @crazyfm6312
    @crazyfm6312 6 лет назад +5

    sir i cannot get it

  • @AbualHassanPervaizAkther
    @AbualHassanPervaizAkther 4 года назад +2

    I was confident now confused :/

  • @sara1010
    @sara1010 3 года назад

    You are doing everything beside what you said you should do.

  • @akashtakawale9074
    @akashtakawale9074 4 года назад +1

    Second paramter of both find and findIndex functions i.e index is not neccesary and we have not even used it.

  • @travezripley
    @travezripley 5 лет назад

    Thank you @Hitesh! This was the solution I was looking for!

  • @ashutoshcbr1988
    @ashutoshcbr1988 5 лет назад +4

    08:10 "callback functions are simple functions with no name" Thats not true.

    • @ppg3530
      @ppg3530 4 года назад

      Did he mean anonymous function instead of callback functions there.

  • @crystalchaung1576
    @crystalchaung1576 3 года назад

    I am learning about accessing objects inside arrays for the reduce method. I got stuck at [9:24]. What is happening with the strict comparison operator? From what I see, the line seems fine until that point.

  • @80Vikram
    @80Vikram 5 лет назад +1

    9:42, is it "every single array" or "every single array element" ?

  • @user-wb5ox7nw2u
    @user-wb5ox7nw2u 5 лет назад

    really simple as ever

  • @harsh8580
    @harsh8580 6 лет назад +6

    bhai ji ,u r taking same examples(todo type)which is confusing mee alot ,if posible can u change the example names

  • @rippybrar1819
    @rippybrar1819 4 года назад

    findIndex(todo) works fine like this too. What is the purpose of passing index in the parameters

  • @debendrasahu6650
    @debendrasahu6650 6 лет назад

    Waiting for your next video sir
    It's quite amazing and interesting

  • @lohithkumar8257
    @lohithkumar8257 6 лет назад

    jai hoo....hitesh bhai

  • @tvshows1344
    @tvshows1344 6 лет назад

    hi sir,
    I am seeing your SQL injecton course. there i have a doubt! after some website as you type "?id=1" and after this you typed a forward slash which showed you an error. but to me the page just loads again. even if type a comma near it. whatt does that mean??

  • @jl-dq5ch
    @jl-dq5ch 5 лет назад +1

    damn, that bottle is awesome =O

  • @hardik.motwani
    @hardik.motwani 5 лет назад

    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?

  • @adarshtodi1158
    @adarshtodi1158 4 года назад

    *EXPLANATION Xd*
    what we are doing here is : Searching a property of an object inside an array using find index inside a function which calls a lowecase comparison between the object title and the tile of the parameter which is passed through callback function of findIndex inside a function variable..
    So basically in simple words. We pass two arguments inside a function called todo, which has a variable and that variable stores index of the tile which we need to find. And that is found via findindex method and that method requires you to enter an callback function. And inside that function.. A simple comparison is done so that when you have any case sensitivity error while searching then the output will be the same..

  • @sabuein
    @sabuein 3 года назад

    Thank you, brother.

  • @user-wb5ox7nw2u
    @user-wb5ox7nw2u 5 лет назад

    hey, Hitesh I tried array with objects with a different approach to create an alarm with notifications, I got the wrong answer= -1 but I have done everything right
    let Almrem=[
    { day:"monday",
    wake: "up 6:0clock",
    task:"do javascript "

    },
    { day:"Tuesday",
    wakeme:"up 7:00 clock",
    task:"Read Js documentation "
    },
    { day:"wednesday",
    wakeme:"up 5:00 clock ",
    task: "watch Naruro shippuden "
    } ,
    ]
    let mummy=Almrem.findIndex(function(eleme,index)
    {
    return Almrem.day ==="monday"
    }
    )
    I'm getting output
    -1

  • @karunakaran7
    @karunakaran7 4 года назад

    this helped me. thanks a lot

  • @bhumimehta7906
    @bhumimehta7906 6 лет назад

    hi Hitesh, I want to know about Delphi language and future scope of it, can you give me some information about it?

  • @vishalagarwal7707
    @vishalagarwal7707 4 года назад

    Well, the whole confusion here is because of the concept that was taught in earlier videos and what is being used here.
    Concepts taught: Arrays & Objects
    Array definition: let someArray = [element1, element2, element3,element4] (Note elements can be of any type, for ex: element1 can be integer, element2 can be string, element3 can be function and element4 can be object)
    & The concept used: Array of Objects i.e.
    let someComplexArray = [{element1}, {element2}, {element3}, {element4}]
    so now, from the video we can understand newTodos is basically is of the above type. one reason for using "arrays of objects" can be for using predefined array functions { just like findIndex() } and array elements can be called by their index, which is not the case with objects and the elements can be accessed without using "this" keyword.
    const newTodos = [
    {title: 'Buy Bread', isDone: false,},
    {title: 'Go to Gym', isDone: false,},
    {title: 'Record youtube videos', isDone: true,}
    ]
    Can you also notice why after isDone: false a comma is not required. ? well, because is the last element of the object and after that, a new object element is created.
    This concept is Array literal with multi objects as values.

    • @chris94kennedy
      @chris94kennedy 4 года назад

      That is not why the confusion exists. It exists because it's a poor choice of iterator for the use-case, and it's badly explained anyway. Please see my recent comment for a detailed explanation and optimal solution.

  • @bapi6060
    @bapi6060 5 лет назад

    If I use the forEach() function, but I have to print only some of the elements in the array (say from index 1 to 5 or index 0 to 8) is it possible to do so?

  • @Haneef30100
    @Haneef30100 5 лет назад

    SO
    findIndex() must be provided a function called predicate. First google that then you will understand.

  • @code_react
    @code_react 4 года назад

    OK what if you have array of objects but you don't know the key and its value. How can you filter through that?

  • @creativeisland1996
    @creativeisland1996 6 лет назад

    u r the best

  • @seekingcode
    @seekingcode 5 лет назад

    Very helpful. Thank you!

  • @aryanshmahato
    @aryanshmahato 5 лет назад +1

    Bhaiya do the giveaway of that bottle!

  • @Ricqua
    @Ricqua 4 года назад +2

    What?! You sound like a good teacher but you totally lost me on this one.

  • @80Vikram
    @80Vikram 5 лет назад

    15:40 why you're not using ";" at the end of statements ?

  • @calvinebun-amu5397
    @calvinebun-amu5397 4 года назад

    Lovely. Thank you .

  • @Submersed24
    @Submersed24 3 года назад

    Do you happen to know how this works in usestate function of react?

  • @umairali2360
    @umairali2360 4 года назад

    try this, i am confusing on this result"on two titles i write down go to cinema but it shows only 1 find index"
    var anotherSearch = [{
    title:'go to school',
    isDone:false
    },{
    title:'go to school',
    isDone:false
    },{
    title:'go to cinema',
    isDone:false
    },{
    title:'go to cinema',
    isDone:true
    }]
    console.log(anotherSearch.findIndex(function(value, index){
    return value.title==='go to cinema'
    }))

  • @IHACKYOU4U
    @IHACKYOU4U 6 лет назад

    Please make video On Spring.

  • @ronit5104
    @ronit5104 6 лет назад +2

    Sir, say somethings in hindi
    By the way videos quality is excellent

  • @rthosarrohini
    @rthosarrohini 4 года назад

    Make video on how to store user input(dom inputs) into array of objects dynamically?

  • @takhminam6068
    @takhminam6068 4 года назад

    Thank you so much!

  • @mi5956
    @mi5956 5 лет назад +1

    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.

  • @mahmoodkashmiri
    @mahmoodkashmiri 6 лет назад

    Waiting for next video ...

  • @edsonnovaes343
    @edsonnovaes343 3 года назад

    Obrigado

  • @udayyadav3489
    @udayyadav3489 5 лет назад

    you know what, i was travelling in the metro with the exact same bottle and they caught me up thinking it contains alcohol [it looks like that under the scanner] . so just beware of that little cute bottle beast

  • @aeonian_joy
    @aeonian_joy 6 лет назад +2

    This video is not as clear as your previous videos. It is confusing. Doubts are there..

  • @thejasiliemetha
    @thejasiliemetha 4 года назад

    Thank you.

  • @vijayakumarrethinam6603
    @vijayakumarrethinam6603 6 лет назад

    good one

  • @adiishukla196
    @adiishukla196 5 лет назад

    Sir I can use casesensitve

  • @sanyammadaan2396
    @sanyammadaan2396 5 лет назад

    Sir Please make a video on Service Worker using javascript for beginners

  • @Raj-uz9nv
    @Raj-uz9nv 6 лет назад +1

    Little bit difficult this video to understand this concept

  • @aravindkumar8145
    @aravindkumar8145 4 года назад

    [1,2,2,3,5,5,5,7,9,9) => sort this array by no.of repetition

  • @adiishukla196
    @adiishukla196 5 лет назад

    For return prblm u can use find

  • @owdji187
    @owdji187 2 года назад +1

    this bottle is sick

  • @Denzil3386
    @Denzil3386 5 лет назад

    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! ;)

  • @monaarsh1462
    @monaarsh1462 2 года назад

    Cute.....

  • @beastgaming8501
    @beastgaming8501 4 года назад +3

    i watched 3 times still confusing

    • @chris94kennedy
      @chris94kennedy 4 года назад

      Please view my recent comment for a cleaner explanation, using better methods. This is such a misleading video.

  • @sivasumanth
    @sivasumanth 6 лет назад

    Bro how to sort array of json

  • @muhammadkalim
    @muhammadkalim 5 лет назад

    complex way

  • @juliouskaiser1869
    @juliouskaiser1869 4 года назад

    21:06

  • @80Vikram
    @80Vikram 5 лет назад

    18:56 "=" should be "==="

  • @nidhiawasthi4643
    @nidhiawasthi4643 4 года назад

    Plz don't use Todos.... It really confuses sometime

  • @_rtdp_
    @_rtdp_ 6 лет назад

    😊

  • @yashrajanshukla7790
    @yashrajanshukla7790 6 лет назад

    I also have that type of bottles

  • @vivekbhardwaj8295
    @vivekbhardwaj8295 4 года назад

    instead of titleRetrned it should be title object returned

  • @angestu
    @angestu 4 года назад

    const findTodo = function(myTodos, title){
    const index = myTodos.findIndex(function(todo,index){
    return todo.title.toLowerCase() === title.toLowerCase()
    })
    return myTodos[index]
    }
    let printMe = findTodo(newTodos, 'Goto Gym')
    console.log(printMe);
    i have got an undefined message ...

  • @vineetbramhankar8099
    @vineetbramhankar8099 5 лет назад

    i liked the pun at the start ..

  • @adilzamal3218
    @adilzamal3218 5 лет назад +1

    I am skipping this video.

  • @nitinroy1331
    @nitinroy1331 5 лет назад

    My favourite teacher bought a PINK bottle and flexed it :'(

  • @mahendrayadav5060
    @mahendrayadav5060 5 лет назад

    a little bit confusing :(

  • @bhargava8038
    @bhargava8038 6 лет назад

    ☺☺☺☺☺☺☺

  • @piyushmahapatra5402
    @piyushmahapatra5402 4 года назад +1

    Bhai beginners hai ham log,itna complex kyun banaya? :(
    time waste hogaya,abhi kuch dusra dhunddna padega youtube mai.

  • @rachitchoudhary6063
    @rachitchoudhary6063 6 лет назад

    170

  • @aravindkumar8145
    @aravindkumar8145 4 года назад

    This is the interview questions i failed

  • @dhruvrawat6619
    @dhruvrawat6619 5 лет назад

    to complx

  • @niravrk5446
    @niravrk5446 5 лет назад

    Its is the bit hard

  • @tusharkadam7471
    @tusharkadam7471 4 года назад +1

    I was watching this video in 2x speed

  • @abhishekchoudhary1919
    @abhishekchoudhary1919 5 лет назад

    too confusing

  • @anshulkanwar1
    @anshulkanwar1 4 года назад

    Todo tudu todu tudu tudu tudu tu doooooooooo

    • @adarshtodi1158
      @adarshtodi1158 4 года назад

      tuturuuuuu (search this word on youtube for more fun..)

  • @SilverTheFlame
    @SilverTheFlame 4 года назад

    No offense, but you do not explain what you're doing well here. This is one of those coding videos that is NOT helpful. At one point you even said that something was obvious when you hadn't explained it! You can't just assume all viewers know what you're talking about!!