DOM Flashcards

1
Q

Why do we log things to the console?

A

To verify the value, debug, and visualize input and outputs.

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

What is a “model”?

A

general representation, copy

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

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

A

HTML document

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

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

A

JavaScript objects: a data type that can hold values

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

What is a DOM Tree?

A

series of objects that make up the HTML document

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

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

A

.querySelector(), getElementbyId()

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

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

A

.queryselectorAll()

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

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

A

it’s faster and for organizational purposes

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

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

A

console.dir()

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

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

A

so that it loads till the very end

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

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

A

CSS selector and return the first element that matches the pattern

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

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

A

returns a NodeList

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

Why do we log things to the console?

A

debugging

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

What is the purpose of events and event handling?

A

respond to user events

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

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

A

No,

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

What method of element objects lets you set up a function to be called when a specific type of event occurs?

A

addEventListener()

17
Q

What is a callback function?

A

function definition that is passed on as a value

18
Q

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

A

the event object

19
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 place where the event began

20
Q

What is the difference between these two snippets of code?

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

A

one is a callback function and another is a function with no parameter

21
Q

Does the document.createElement() method insert a new element into the page?

A

no it creates a new element

22
Q

How do you add an element as a child to another element?

A

appendChild

23
Q

What do you pass as the arguments to the element.setAttribute() method?

A

name of the attribute and the value of the attribute

24
Q

What steps do you need to take in order to insert a new element into the page?

A

get the thing we want to add to and then do create Element

25
Q

What is the textContent property of an element object for?

A

to change the text content pr retrieve the text conetent

26
Q

Name two ways to set the class attribute of a DOM element.

A

setAttrribute , className

27
Q

What are two advantages of defining a function to do create something (like the work of creating a DOM tree)?

A

reusablity, and control