This JavaScript interview question exposes a very common mistake that college students, freshers, and React interview candidates make while working with event listeners. In this example, a click event listener is added and then removed using removeEventListener. At first glance, the code looks perfectly fine — but when the button is clicked, the event still fires. Why? Because in JavaScript, removeEventListener only works when you pass the exact same function reference that was used while adding the event listener. Even though both arrow functions look identical, they are actually two different functions in memory, so the event listener is never removed. In this short, I explain: Why removeEventListener fails with anonymous functions How function references work in JavaScript A common JavaScript interview trap The correct fix using a named function Why this concept is important for React and frontend interviews 👉 Key takeaway: If you plan to remove an event listener, always store the handler in a variable or use a named function. This concept is frequently tested in: JavaScript interviews Frontend developer interviews React interviews College placement rounds If you’re preparing for React, JavaScript, or frontend interviews, this is a must-know concept that can easily cost you an interview if misunderstood. 📌 Follow for more JavaScript interview questions, React interview prep, and placement-focused explanations. #devshorts #events #javascriptinterviewquestions #programming #dommanipulation #dom #codingtips #codingtips #asyncjavascript #asynchronousjavascript #async #reactinterview #frontendinterview #javascriptshorts #code #college #collegestudent #freshers #learnjavascript #interviewpreparation