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 :)
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❤️❤️
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".
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
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.
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.
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
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.
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
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.
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??
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?
*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..
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 "
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.
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.
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?
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' }))
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
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! ;)
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!!
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 :)
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❤️❤️
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".
Finally, someone who explains that parameter/argument/variable names could be just made up. Thank you Hitesh.
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
I like your videos a lot, but not this one. I found this one is not as clearly-taught as your previous videos.
Totally...confused
go through all the documentaion for the findIndex() all of your confusions will be solved trust me!!! video is amazing thank u soo much
Ok. I am going for it. If i am confused afterwards, u r ded 😪
Enjoying the series,sir. If possible make video about machine learning with javascript and how to get started.
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.
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.
understand it as forEach
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
why are you setting all your functions inside a variable?
This video is confusing. I'm confused a bit. Previous videos are much more clear. Help.
Amazing style of teaching you have, really impressed!
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.
Great explanation in very easy way sir......
Sir I watch video 5 to 6 time still I am little bit confused what should I do
Too late. Change teacher
Tip 1 : "Keep Moving" 😂♥️
Awesome! Thank you for your tuition. It's very useful for me.🤝
video is Awsom and guys how have confusion in that , they read documentation things gets more clear !!!!
This things can be done much more easily you are going little complex here
Yeah
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
@@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;
}
Incredibly confusing video, after watching 3 times also I understood nothing, really very complex.
same heree
Dude you are the best.
Really no words hithesh bro ... Definitely some people's learn & earn your videos via ... Nyc nyc
Love your teaching style! Thanks!
sir i cannot get it
I was confident now confused :/
You are doing everything beside what you said you should do.
Second paramter of both find and findIndex functions i.e index is not neccesary and we have not even used it.
Thank you @Hitesh! This was the solution I was looking for!
08:10 "callback functions are simple functions with no name" Thats not true.
Did he mean anonymous function instead of callback functions there.
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.
9:42, is it "every single array" or "every single array element" ?
every single element in array
really simple as ever
bhai ji ,u r taking same examples(todo type)which is confusing mee alot ,if posible can u change the example names
findIndex(todo) works fine like this too. What is the purpose of passing index in the parameters
Waiting for your next video sir
It's quite amazing and interesting
jai hoo....hitesh bhai
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??
damn, that bottle is awesome =O
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?
*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..
Thank you, brother.
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
this helped me. thanks a lot
hi Hitesh, I want to know about Delphi language and future scope of it, can you give me some information about it?
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.
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.
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?
SO
findIndex() must be provided a function called predicate. First google that then you will understand.
OK what if you have array of objects but you don't know the key and its value. How can you filter through that?
u r the best
Very helpful. Thank you!
Bhaiya do the giveaway of that bottle!
What?! You sound like a good teacher but you totally lost me on this one.
Lmao 😂
15:40 why you're not using ";" at the end of statements ?
Lovely. Thank you .
Do you happen to know how this works in usestate function of react?
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'
}))
Please make video On Spring.
Sir, say somethings in hindi
By the way videos quality is excellent
Make video on how to store user input(dom inputs) into array of objects dynamically?
Thank you so much!
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.
Waiting for next video ...
Obrigado
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
This video is not as clear as your previous videos. It is confusing. Doubts are there..
I agree
agree
Thank you.
good one
Sir I can use casesensitve
Sir Please make a video on Service Worker using javascript for beginners
Little bit difficult this video to understand this concept
[1,2,2,3,5,5,5,7,9,9) => sort this array by no.of repetition
For return prblm u can use find
this bottle is sick
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! ;)
Cute.....
i watched 3 times still confusing
Please view my recent comment for a cleaner explanation, using better methods. This is such a misleading video.
Bro how to sort array of json
complex way
21:06
18:56 "=" should be "==="
Plz don't use Todos.... It really confuses sometime
😊
I also have that type of bottles
instead of titleRetrned it should be title object returned
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 ...
i liked the pun at the start ..
I am skipping this video.
My favourite teacher bought a PINK bottle and flexed it :'(
a little bit confusing :(
☺☺☺☺☺☺☺
Bhai beginners hai ham log,itna complex kyun banaya? :(
time waste hogaya,abhi kuch dusra dhunddna padega youtube mai.
170
This is the interview questions i failed
to complx
Its is the bit hard
I was watching this video in 2x speed
RIP
too confusing
Todo tudu todu tudu tudu tudu tu doooooooooo
tuturuuuuu (search this word on youtube for more fun..)
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!!