dom-events Flashcards

1
Q

Why do we log things to the console?

A

checking functionality and check data; test code and debug

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

What is the purpose of events and event handling?

A

to trigger a function; make the page feel more interactive

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

What do [] square brackets mean in function and method syntax documentation?

A

it means that it is optional

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

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

A

addEventListener method

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

event object

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

a reference to the value of the object onto which the event was dispatched. check with 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

the latter code will call the function immediately

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

what is a callback function?

A

a function being called into another function as an argument

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