Hello, in this jQuery video, we are going to cover the each method in jQuery. So the each method is a really simple iterator that allows you to go over an array, for example, or an object really easily without having to manually check for, you know, manually typing each index. If you only have an array of about the same size five, doing each index is fine. But if you have an array of size 100, or you might not know the exact size, then using a iterator such as the each method is useful. So first of all, let's create an array bar array. You can do this with an object as well that has a key value pair, but we're just going to keep it simple and use an array.
Once you got the code and you understand it from this video. The the the actual jQuery each method code will be exactly the same To use that for objects as well, square brackets because it's a, an array, and let's put some values here. I will, Batman pizza that will just keep it simple is free, but you can put as many as you want in your array. And if I do dollar dot each parameter it requires give the array name array in this case, function callback. And this will take two parameters index and you could obviously name it whatever you like. I'm just going to call them index and value just because they explain what they do.
And now we are just going to print it out. You could actually I'll cover that in a moment. What else you could do limits and value. Now if we run it, see what we get. Okay, so he says 01, and two. So this is the index zero, because everything in computer starts with 012.
Those are the, the indexes for each one. And we have the values Batman pizza, and Yoda. So it doesn't matter how long your array allows you to iterate over it really. So index is, you know, the index that you value is that value, if the value it sells for you was using an object that had a key value pair, the index would be the key, and the value would obviously be the corresponding value. So the other thing that you can do with something like this, each method, instead of just logging it to the console, which isn't that useful, is to pour it into HTML. You could use HTML All methods, which we've already covered in the HTML part of the series, to put into a list, for example, so the next task, only to put it into a ordered list and see what it looks like.
So that's it for this video. If you have any questions, feel free to drop me a message. And as usual, I look forward to seeing you in the next video.