24 modern ES6 code snippets to solve practical JS problems

PHOTO EMBED

Fri Mar 05 2021 19:31:07 GMT+0000 (UTC)

Saved by @w_jellett

const toggleClass = (el, className) => el.classList.toggle(className);

// Example
toggleClass(document.querySelector('p.special'), 'special'); 
// The paragraph will not have the 'special' class anymore
content_copyCOPY

https://madza.hashnode.dev/24-modern-es6-code-snippets-to-solve-practical-js-problems?guid