What are the differences between .addEventListener("resize",function(){}) and .onresize = function(){} ?

1 answer 1

addEventListener allows you to add multiple handlers for a single action. Conveniently, if you use third-party libraries and cannot be sure that no one else except you has installed its handler.

  • And what are the names of methods like .onresize (well, there are EventListeners, but what is this?). - user323354
  • Himself onresize and similar ones are called events. The functions that you put in them are event handlers. - German Borisov