DOM Events Flashcards

1
Q

Why do we log things to the console?

A

To check data (values of variables) and to verify if the codes are working correctly (double check functionality).
Logging things to console = developers way for verification.

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

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

A

It means that it’s optional.

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( ) method

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

What is the difference between these two snippets of code?

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

A

1 ) add.EventListener will receive the arguments: string ‘click’ and a function definition for handleClick.
2) add.EventListener will receive the arguments: string ‘click’ and the return value from handleClick.

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

What is the purpose of events and event handling?

A

Without events, the page would be static. Events make it possible for things to occur in the browser. Event handling makes it possible for us to respond to an event.

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

What is a callback function?

A

A function named that can be passed through to be used somewhere else.

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

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

A

An object with all the information about the event.

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

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

A

Event.target is a property which holds a reference to the html element that triggers the event firing in the first place.
Look up on MDN documentation for more information.

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