Skip to content

Instantly share code, notes, and snippets.

View jomlamladen's full-sized avatar
💻

Mladen Milicevic jomlamladen

💻
View GitHub Profile
@jomlamladen
jomlamladen / foreach.js
Created January 14, 2020 14:50 — forked from cferdinandi/foreach.js
A simple forEach() implementation for Arrays, Objects and NodeLists. Forked from ForEach.js by Todd Motto. https://github.com/toddmotto/foreach
/**
* A simple forEach() implementation for Arrays, Objects and NodeLists
* @private
* @param {Array|Object|NodeList} collection Collection of items to iterate
* @param {Function} callback Callback function for each iteration
* @param {Array|Object|NodeList} scope Object/NodeList/Array that forEach is iterating over (aka `this`)
*/
var forEach = function (collection, callback, scope) {
if (Object.prototype.toString.call(collection) === '[object Object]') {
for (var prop in collection) {