Question · JavaScript and TypeScript course · Module 8: Events and the DOM

The component's destroy() method

Why should a component remove its event listeners in the destroy() method?

Answer options

  • To prevent memory leaks after the component is removed
  • To change the component's color
  • To speed up the CSS animation
  • To automatically save data to the server

You can check the correct answer by solving this task in the CodeWorlds game.