Solution Review: Arrow Functions
In this lesson, we will discuss the solutions to the questions in the previous lesson.
We'll cover the following...
Press + to interact
<style>button {font-size: 50px; }.on {background: #ff0000;}</style><button id="pushy">Click me</button>
Press + to interact
const button = document.querySelector('#pushy');button.addEventListener('click', () => {this.classList.toggle('on');});
For the codes above, you were asked the following question:
Explanation
In JavaScript, arrow functions do not bind their own this
, meaning they inherit the one from the parent scope; this is also known as lexical scoping. ...