dom events Flashcards

1
Q

Why do we log things to the console?

A

To observe things

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 control behavior for certain events

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

No, there are some functions that have optional parameters

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

myElement.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 taken as an argument of another function and is invoked inside that function. syntax is:
callback(params);
where callback is the literal word being used

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 object receiving the notification when the even occurs

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

it is the property of the event that is the element being interacted with
you can check with console.log(event.target);
console

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?

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

A

the first will wait for the notification to run

the second will immediately run

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