dom-events Flashcards

1
Q

Why do we log things to the console?

A

debugging, confirming values or outcomes from code, communicating with other devs working on the project

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

events let us know something has occured. Event Handling allows us to take an action based on what event has occured such as running a function or changing the display of the website.

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

yes

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

it is a method of an object that is called when a specific type of event occurs

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

an 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 event.target property refers to the element that the event occurred on. you can console log it. you can open inspector to get more info.

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

handleClick is a reference to the function, and the function is not called until the element is clicked.

In the second case, handleClick() is actually invoked immediately, and the result of the function is passed to addEventListener as the event handler.

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