this
's value is not the same in a regular function as in an arrow function:- inside a regular function: it refers to whatever
this
value the function is called uponfunction toggleOpen() { this.classList.toggle('open'); // Here `this` refers to `panel` setTimeout(() => this.classList.toggle('open-active'), 900); }; panels.forEach(panel => panel.addEventListener('mouseover', toggleOpen));
- inside an arrow function: it refers to the global
this
- inside a regular function: it refers to whatever
This repository has been archived by the owner on Oct 11, 2019. It is now read-only.