Skip to content
This repository has been archived by the owner on Oct 11, 2019. It is now read-only.

Latest commit

 

History

History
11 lines (10 loc) · 525 Bytes

File metadata and controls

11 lines (10 loc) · 525 Bytes
  • 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 upon
      function 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