DOM-events Flashcards

1
Q

Why do we log things to the console?

A

To see what’s going on without having to find the issue later.

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

They notify code of interesting changes.

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

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

A

Not sure.

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

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

What is a callback function?

A

A function passed into another function as an argument.

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

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

A

The event object

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

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

A

The target event property returns the element that triggered the event. Where the interaction took place.

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

What is the difference between these two snippets of code?

A

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

In the 1st, the 2nd argument is the function named handleClick, in the 2nd argument, the 2nd argument is being called. We’re passing a function definition.

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