Simple forEach for JavaScript Objects and Array

I got fed up today with having to do for loops in JavaScript. Having to do the checks for “hasOwnProperty” etc. is really so tedious and makes your code messier and just more difficult to read. Even though there is an iterator for Arrays (, there isn’t any for Objects so I decided to write one to use in the code for my projects and thought I may as well release for anyone that may need something quick.

The for each method that I’ve written will work for both arrays and objects and will work slightly differently depending on which type it is. By default it will ignore functions on objects and only return properties. I’ve uploaded both it and a bunch of examples on how to use it to my GitHub account at .

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s