Very informative post! I just wanted to mention that in the case of events handled by addEventListener, if you pass an object that implements #handleEvent, it will be called with event as its argument, and it will be implicitly bound to the object passed in to addEventListener. If you call any other functions on the object within the body of handleEvent, they will also be implicitly bound to the object, too! This saves memory by preventing you from having to use #bind or the arrow syntax for those functions, which both create copies of the function in question,. In circumstances where you have a large number of objects, this can save you a ton of overhead!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Very informative post! I just wanted to mention that in the case of events handled by
addEventListener
, if you pass an object that implements#handleEvent
, it will be called withevent
as its argument, and it will be implicitly bound to the object passed in toaddEventListener
. If you call any other functions on the object within the body ofhandleEvent
, they will also be implicitly bound to the object, too! This saves memory by preventing you from having to use#bind
or the arrow syntax for those functions, which both create copies of the function in question,. In circumstances where you have a large number of objects, this can save you a ton of overhead!