Skip to content

Instantly share code, notes, and snippets.

@darcher-
Created September 26, 2018 09:17
Show Gist options
  • Save darcher-/4b75b38d1f886ba6223d49d44cfb9b69 to your computer and use it in GitHub Desktop.
Save darcher-/4b75b38d1f886ba6223d49d44cfb9b69 to your computer and use it in GitHub Desktop.
var elements = document.querySelectorAll('div');
callback = (el) => { console.log(el); };
// Spread operator
elements[Symbol.iterator]();
elements.forEach(callback) //[...elements].forEach(callback);
// Array.from()
Array.from(elements, callback) //Array.from(elements).forEach(callback);
// for...of statement
for (let div of elements) callback(div);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment