JS DOM Manipulation and Events Flashcards
What is the primary advantage to storing your selected elements in a variable?
it can be reused
Why might you need JS to modify the DOM after the page loads?
gives user interactivity
How can you better prepare when writing HTML for DOM manipulation in your JS code?
set ID and class attribues
What are the differences between innertext and textContent?
innertext will show what is seen, and textContent will give you everything
What datatypes are the values you remove from a text input?
anything you want updated
Why is it so important to be able to dynamically update text
in response to users
What are some of the drawbacks of HTML Event Handler Attributes?
code is mixed with HTML which makes the code more difficult to maintain and extend. Timing issue as well.
Why is the Window.event property to be avoided in new code?
because it changes with every event and becomes chaotic
Why is the Window.event property useful for finding and element which was interacted with?
gives us a direct channel to that element
What is the difference between getElementById and querySelector?
query selector will receive a css selector and get element by Id is only ids
Who passes in the event object into the handleClick callback function?
the JS language
Does a callback function require a name?
NO
What is the purpose of a loop?
loops checks a condition and repeats until the condition returns false.Lets you repeat functionality
Why might there be different kinds of loops?
depending on the situation. if you do not know how many times the code should run use a while loop, and if you need to run a code at a specific number of times use a for loop
What is the purpose of a conditional expression as it relates to loops?
indicator when we are finished
Could a loop potentially go on forever?
Yes
Could a loop never start?
Yes, if you don’t configure them right
How does a for loop differ from a while loop?
while loops only need the end point and for loop are useful for knowing exactly how many times you need to use it
What potential use cases are there for for loop?
for a search in a search engine. for arrays
Which pieces of info provided in the parenthesis for a for loop are mandatory?
none of them are mandatory