So the jQuery each method is a simple tool to loop over an object or array. This is not the first post I have written on a tool that does this, I wrote a post on the npm package traverse that is another tool that does basically the same thing. yes there is Array.forEach, the for in loop, and a wide range of other options that come to mind, but for now lets just keep it with an option in jQuery.
In vanilla js typically looping over an object in general is done with a for in loop. It is not that hard to quickly write my own methods for this one.
There are many other ways to do so, there is of course Array.forEach, and also while loops. However Array.forEach is only for Arrays, or regular Objects that look like arrays.
However the use of a while loop might be a nice change to my each method
But what am I doing wasting time writing my own methods for something that is so basic and trivial? Good question that is why there are all ready methods like this in many popular projects like jQuery.
yes there is no need to write that method, if there is something that will get the job done to begin with.
So one idea that comes to mind is to use jQuerys each method to look over jQuerys core object.
This is something that I like to do whenever working with something new, just to get a sense of what it is that I am working with.
I have been writing posts at the rate of about one per day lately, as such quality is taking a hit. Maybe I will come back to this one at some point but there is not much to write about on it. Just another way to loop over an object.