JavaScript Flashcards
Why do we log things to the console?
To test if the code is working
What is a “model”?
contains the interactive data
Which “document” is being referred to in the phrase Document Object Model?
html
What is a DOM Tree?
as a browser loads a web page it creates a model of that page and it consists of four types of nodes the document node element node attribute and text nodes.
Give two examples of document methods that retrieve a single element from the DOM.
getElementById and querySelector:
Give one example of a document method that retrieves multiple elements from the DOM at once.
querySelectorAll
Why might you want to assign the return value of a DOM query to a variable?
In order to console log
What console method allows you to inspect the properties of a DOM element object?
console dir
Why would a tag need to be placed at the bottom of the HTML content instead of at the top?
it gives the html body time to load before any of the javascript loads
What does document.querySelector() take as its argument and what does it return?
returns the first element
What does document.querySelectorAll() take as its argument and what does it return?
returns a static node list
What is the word “object” referring to in the phrase Document Object Model?
the nodes of a dom tree
Why do we log things to the console?
to inform developers what the code is doing
What is the purpose of events and event handling?
in order to make web content more dynamic and interactable
What do [] square brackets mean in function and method syntax documentation?
Square brackets are used to index (access) elements in arrays and also Strings. Specifically lost[i] will evaluate to the ith item in the array named lost.