Search from array of objects in javascript

  Рет қаралды 129,502

Hitesh Choudhary

Hitesh Choudhary

Күн бұрын

Пікірлер: 128
@mananpatel9802
@mananpatel9802 4 жыл бұрын
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 KZbin :)
@gravelessForever
@gravelessForever 4 жыл бұрын
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".
@nusrathfatima7095
@nusrathfatima7095 5 жыл бұрын
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❤️❤️
@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
@sanudajayathilaka3173
@sanudajayathilaka3173 5 жыл бұрын
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 😪
@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 жыл бұрын
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 жыл бұрын
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
@dilipgautam
@dilipgautam 6 жыл бұрын
Enjoying the series,sir. If possible make video about machine learning with javascript and how to get started.
@kaituo1803
@kaituo1803 6 жыл бұрын
I like your videos a lot, but not this one. I found this one is not as clearly-taught as your previous videos.
@kumarkanav
@kumarkanav 6 жыл бұрын
Totally...confused
@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 жыл бұрын
This things can be done much more easily you are going little complex here
@niharranjanbhuyan9839
@niharranjanbhuyan9839 6 жыл бұрын
Yeah
@songlee8456
@songlee8456 6 жыл бұрын
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 жыл бұрын
@@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; }
@poojaanandan3869
@poojaanandan3869 5 жыл бұрын
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.
@mfklogsaif
@mfklogsaif 5 жыл бұрын
Amazing style of teaching you have, really impressed!
@sachintiwari5871
@sachintiwari5871 6 жыл бұрын
Great explanation in very easy way sir......
@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..
@yashshende2786
@yashshende2786 6 жыл бұрын
Sir I watch video 5 to 6 time still I am little bit confused what should I do
@kushalthapa2865
@kushalthapa2865 4 жыл бұрын
Too late. Change teacher
@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.
@yugankumar6416
@yugankumar6416 5 жыл бұрын
Tip 1 : "Keep Moving" 😂♥️
@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
@mohitnayak5049
@mohitnayak5049 5 жыл бұрын
This video is confusing. I'm confused a bit. Previous videos are much more clear. Help.
@sara1010
@sara1010 3 жыл бұрын
You are doing everything beside what you said you should do.
@GorillaDev417
@GorillaDev417 4 жыл бұрын
Love your teaching style! Thanks!
@rahulagnihotri344
@rahulagnihotri344 4 жыл бұрын
Incredibly confusing video, after watching 3 times also I understood nothing, really very complex.
@manishshrestha241
@manishshrestha241 3 жыл бұрын
same heree
@rippybrar1819
@rippybrar1819 4 жыл бұрын
findIndex(todo) works fine like this too. What is the purpose of passing index in the parameters
@tim.bogdanov
@tim.bogdanov 4 жыл бұрын
why are you setting all your functions inside a variable?
@travezripley
@travezripley 5 жыл бұрын
Thank you @Hitesh! This was the solution I was looking for!
@user-wb5ox7nw2u
@user-wb5ox7nw2u 5 жыл бұрын
really simple as ever
@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.
@lohithkumar8257
@lohithkumar8257 6 жыл бұрын
jai hoo....hitesh bhai
@Submersed24
@Submersed24 3 жыл бұрын
Do you happen to know how this works in usestate function of react?
@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??
@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?
@debendrasahu6650
@debendrasahu6650 6 жыл бұрын
Waiting for your next video sir It's quite amazing and interesting
@crazyfm6312
@crazyfm6312 6 жыл бұрын
sir i cannot get it
@sabuein
@sabuein 3 жыл бұрын
Thank you, brother.
@akashtakawale9074
@akashtakawale9074 4 жыл бұрын
Second paramter of both find and findIndex functions i.e index is not neccesary and we have not even used it.
@jl-dq5ch
@jl-dq5ch 5 жыл бұрын
damn, that bottle is awesome =O
@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?
@Ricqua
@Ricqua 4 жыл бұрын
What?! You sound like a good teacher but you totally lost me on this one.
@mystique1127
@mystique1127 4 жыл бұрын
Lmao 😂
@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?
@creativeisland1996
@creativeisland1996 6 жыл бұрын
u r the best
@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
@Haneef30100
@Haneef30100 5 жыл бұрын
SO findIndex() must be provided a function called predicate. First google that then you will understand.
@karunakaran7
@karunakaran7 4 жыл бұрын
this helped me. thanks a lot
@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?
@ashutoshcbr1988
@ashutoshcbr1988 5 жыл бұрын
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.
@80Vikram
@80Vikram 5 жыл бұрын
9:42, is it "every single array" or "every single array element" ?
@user-wb5ox7nw2u
@user-wb5ox7nw2u 5 жыл бұрын
every single element in array
@harsh8580
@harsh8580 6 жыл бұрын
bhai ji ,u r taking same examples(todo type)which is confusing mee alot ,if posible can u change the example names
@aravindkumar8145
@aravindkumar8145 4 жыл бұрын
[1,2,2,3,5,5,5,7,9,9) => sort this array by no.of repetition
@seekingcode
@seekingcode 5 жыл бұрын
Very helpful. Thank you!
@mahmoodkashmiri
@mahmoodkashmiri 6 жыл бұрын
Waiting for next video ...
@calvinebun-amu5397
@calvinebun-amu5397 4 жыл бұрын
Lovely. Thank you .
@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' }))
@adiishukla196
@adiishukla196 5 жыл бұрын
Sir I can use casesensitve
@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
@rthosarrohini
@rthosarrohini 4 жыл бұрын
Make video on how to store user input(dom inputs) into array of objects dynamically?
@aryanshmahato
@aryanshmahato 5 жыл бұрын
Bhaiya do the giveaway of that bottle!
@80Vikram
@80Vikram 5 жыл бұрын
15:40 why you're not using ";" at the end of statements ?
@AbualHassanPervaizAkther
@AbualHassanPervaizAkther 4 жыл бұрын
I was confident now confused :/
@ronit5104
@ronit5104 6 жыл бұрын
Sir, say somethings in hindi By the way videos quality is excellent
@sanyammadaan2396
@sanyammadaan2396 6 жыл бұрын
Sir Please make a video on Service Worker using javascript for beginners
@vijayakumarrethinam6603
@vijayakumarrethinam6603 6 жыл бұрын
good one
@thejasiliemetha
@thejasiliemetha 5 жыл бұрын
Thank you.
@aeonian_joy
@aeonian_joy 6 жыл бұрын
This video is not as clear as your previous videos. It is confusing. Doubts are there..
@kumarkanav
@kumarkanav 6 жыл бұрын
I agree
@mohitnayak5049
@mohitnayak5049 5 жыл бұрын
agree
@edsonnovaes343
@edsonnovaes343 3 жыл бұрын
Obrigado
@IHACKYOU4U
@IHACKYOU4U 6 жыл бұрын
Please make video On Spring.
@takhminam6068
@takhminam6068 4 жыл бұрын
Thank you so much!
@owdji187
@owdji187 2 жыл бұрын
this bottle is sick
@nitinroy1331
@nitinroy1331 5 жыл бұрын
My favourite teacher bought a PINK bottle and flexed it :'(
@Raj-uz9nv
@Raj-uz9nv 6 жыл бұрын
Little bit difficult this video to understand this concept
@beastgaming8501
@beastgaming8501 4 жыл бұрын
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.
@adiishukla196
@adiishukla196 5 жыл бұрын
For return prblm u can use find
@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! ;)
@muhammadkalim
@muhammadkalim 5 жыл бұрын
complex way
@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 ...
@mi5956
@mi5956 5 жыл бұрын
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.
@vivekbhardwaj8295
@vivekbhardwaj8295 4 жыл бұрын
instead of titleRetrned it should be title object returned
@yashrajanshukla7790
@yashrajanshukla7790 6 жыл бұрын
I also have that type of bottles
@sivasumanth
@sivasumanth 6 жыл бұрын
Bro how to sort array of json
@vineetbramhankar8099
@vineetbramhankar8099 5 жыл бұрын
i liked the pun at the start ..
@tusharkadam7471
@tusharkadam7471 4 жыл бұрын
I was watching this video in 2x speed
@adarshtodi1158
@adarshtodi1158 4 жыл бұрын
RIP
@aravindkumar8145
@aravindkumar8145 4 жыл бұрын
This is the interview questions i failed
@nidhiawasthi4643
@nidhiawasthi4643 4 жыл бұрын
Plz don't use Todos.... It really confuses sometime
@monaarsh1462
@monaarsh1462 3 жыл бұрын
Cute.....
@adilzamal3218
@adilzamal3218 5 жыл бұрын
I am skipping this video.
@80Vikram
@80Vikram 5 жыл бұрын
18:56 "=" should be "==="
@juliouskaiser1869
@juliouskaiser1869 4 жыл бұрын
21:06
@piyushmahapatra5402
@piyushmahapatra5402 4 жыл бұрын
Bhai beginners hai ham log,itna complex kyun banaya? :( time waste hogaya,abhi kuch dusra dhunddna padega youtube mai.
@_rtdp_
@_rtdp_ 6 жыл бұрын
😊
@bhargava8038
@bhargava8038 6 жыл бұрын
☺☺☺☺☺☺☺
@mahendrayadav5060
@mahendrayadav5060 5 жыл бұрын
a little bit confusing :(
@anshulkanwar1
@anshulkanwar1 4 жыл бұрын
Todo tudu todu tudu tudu tudu tu doooooooooo
@adarshtodi1158
@adarshtodi1158 4 жыл бұрын
tuturuuuuu (search this word on youtube for more fun..)
@niravrk5446
@niravrk5446 5 жыл бұрын
Its is the bit hard
@dhruvrawat6619
@dhruvrawat6619 5 жыл бұрын
to complx
@rachitchoudhary6063
@rachitchoudhary6063 6 жыл бұрын
170
@erfanasgari21
@erfanasgari21 6 жыл бұрын
f** specially because of the bottle
@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!!
Moving forward in JS - Paths
3:14
Hitesh Choudhary
Рет қаралды 26 М.
Maps and for of loop in javascript
22:35
Hitesh Choudhary
Рет қаралды 44 М.
Trick-or-Treating in a Rush. Part 2
00:37
Daniel LaBelle
Рет қаралды 44 МЛН
Ice Cream or Surprise Trip Around the World?
00:31
Hungry FAM
Рет қаралды 10 МЛН
Classes and objects in javascript
16:30
Hitesh Choudhary
Рет қаралды 82 М.
React State Array of Objects
20:55
Sam Meech-Ward
Рет қаралды 26 М.
Arrow function basics in javascript 😃
13:41
Hitesh Choudhary
Рет қаралды 65 М.
Username and Password checking basics in javascript
15:36
Hitesh Choudhary
Рет қаралды 63 М.
Methods and this keyword in javascript
13:55
Hitesh Choudhary
Рет қаралды 63 М.
Coercion in Javascript
14:53
Hitesh Choudhary
Рет қаралды 37 М.
JavaScript Array Mastery: Tips, Tricks & Best Practices
1:02:49
Envato Tuts+
Рет қаралды 26 М.
Easy Ways to Loop Over Objects in JavaScript
11:21
dcode
Рет қаралды 11 М.
JavaScript Search Bar
14:57
James Q Quick
Рет қаралды 169 М.