Skip to content

Instantly share code, notes, and snippets.

@maxboeck
Last active April 2, 2019 13:32
Show Gist options
  • 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