Skip to content

Instantly share code, notes, and snippets.

Avatar
💻

Mladen Milicevic jomlamladen

💻
  • Digital Bridges
  • Serbia
View GitHub Profile
@jomlamladen
jomlamladen / foreach.js
Created Jan 14, 2020 — 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
View foreach.js
/**
* 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) {