JS Flashcards

1
Q

What is the className property of element objects?

A

Property holding the class attribute of that element

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

How do you update the CSS class attribute of an element using JavaScript?

A

object name.class name

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

What is the textContent property of element objects?

A

The text containing the element and it’s children

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

How do you update the text within an element using JavaScript?

A

objectname.text content

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

Is the event parameter of an event listener callback always useful?

A

not always

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

Would this assignment be simpler or more complicated if we didn’t use a variable to keep track of the number of clicks?

A

more difficult

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

Why is storing information about a program in variables better than only storing it in the DOM?

A

it’s more work for the browser

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

to check for errors

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

What is the purpose of events and event handling?

A

so that developers would scan response

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

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

A

denotes that it’s optional can be provided or not

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

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

A

add event listener

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

What is a callback function?

A

function within a function

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

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

A

a huge object when the event is passed containing all the info

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

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

A

element target which event originated from

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

What is a “model”?

A

a represenation of something

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

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

A

html document

17
Q

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

A

objects in js

18
Q

What is a DOM Tree?

A

map representing all elements and its children

19
Q

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

A

query selector to get element by id

20
Q

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

A

query selector all

21
Q

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

A

store the location of the element

22
Q

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

A

console.dir

23
Q

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

A

allows html elements to load first

24
Q

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

A

element, class, id

25
Q

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

A

css selector, string, returns a node list