Dom-Events Flashcards

1
Q

What is the purpose of events and event handling?

A

Events and event handling allow for certain elements within the HTML doc to be manipulated by user actions while on the webpage.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Are all possible parameters required to use a JavaScript method or function?

A

No.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What method of element objects lets you set up a function to be called when a specific type of event occurs?

A

addEventListener

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a callback function?

A

A callback function is a function that is passed as an argument of another function. The callback function is executed inside the other one.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What object is passed into an event listener callback when the event fires?

A

an object with a handleEvent() method, or a JavaScript function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the event.target? If you weren’t sure, how would you check? Where could you get more information about it?

A

even.target is a reference to the object that the event is acting on. You can check by testing the property in the console or read more about it on MDN

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the difference between these two snippets of code?

element. addEventListener(‘click’, handleClick)
element. addEventListener(‘click’, handleClick())

A

handleClick in the second line is being called.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly