0
what is this called?
----------------------------------------------- like This is object constructor:- function Person(first, last, age, eye) { this.firstName = first; this.lastName = last; this.age = age; this.eyeColor = eye; } ---------------------------------------------- like this is function :- function(){code} ............................................................................ what is the below code called ? addEventListener(event, function, useCapture)
2 Respostas
+ 3
You can call it an event handler I guess
+ 2
It is an event listener. It listens for an event to happen. click, hover, mouseover, dblclick, drag etc. and executes the function.
useCapture is for events that don't do what is called bubbling. Take the click event. If you click on an a tag, that click event will rise up the DOM tree from parent to parent until it reaches the root document. So you could add a listener to that a tag, or to the document and catch all clicks. But something like focus doesn't bubble. Unless you set useCapture to true.