Skip to content

Instantly share code, notes, and snippets.

@maxboeck
Last active April 2, 2019 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxboeck/ade2a0308638cb9d5b5d4a1085bbecab to your computer and use it in GitHub Desktop.
Save maxboeck/ade2a0308638cb9d5b5d4a1085bbecab to your computer and use it in GitHub Desktop.
Array.from mapping function
const allButtons = document.querySelectorAll('button');
const init = btn => {
btn.classList.add('is-initialized');
btn.addEventListener('click', () => console.log(btn, 'clicked'));
return btn;
}
Array.from(allButtons, init);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment