DOM Flashcards

1
Q

Why do we log things to the console?

A

To check and debug code.

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 respond to events in the system that is being programmed.

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

Square brackets in function and method syntax documentation means that the indicated arguments are 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

The addEventListener() method.

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 as an argument to another function.

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 object based on Event describing the event that has occurred.

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

What is the event.target?

A

The target property gets the element on which the event originally occurred

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

Why do we log things to the console?

A

Logging things to the console tells us what the code is doing.

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

What is a “model”?

A

The model makes up the DOM and is made up of objects.

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

Which “document” is being referred to in the phrase Document Object Model?

A

The HTML document.

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

What is the word “object” referring to in the phrase Document Object Model?

A

The Window object.

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

What is a DOM tree?

A

The DOM Model is made up of a tree of objects.

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

Why might you want to assign the return value of a DOM query to a variable?

A

To store the location of elements within a DOM tree.

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

What console method allows you to inspect the properties of a DOM element object?

A

The dir method of the console object.

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

Why would a script tag need to be placed at the bottom of the HTML content instead of at the top?

A

Script tags are placed at the bottom of the HTML page because the browser needs to parse all of the elements before the JavaScript code can access them.

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

What does document.querySelector() take as its argument and what does it return?

A

It takes specified CSS selectors and returns the first Element within the document that matches the those selectors.

17
Q

What does document.querySelectorAll() take as its argument and what does it return?

A

It takes specified CSS selectors and returns a static node list representing a list of the documents elements that match the specified group of selectors.

18
Q

Give two examples of document methods that retrieve a single element from the DOM.

A

document.querySelector() and document.querySelectorAll()

19
Q

Give one example of a document method that retrieves multiple elements from the DOM at once.

A

document.querySelectorAll()