LATEST 2025
A promise is - Answers an object returned by asynchronous code
async/await syntax is syntactic sugar for - Answers promises
the async keyword is added to the front of a - Answers function that should contain
asynchronous code
the await keyword is added to the front of an asynchronous function call that returns - Answers
a promise
the insertAfter() method can be used to add an element to the DOM after a given element (T/F) -
Answers False. There is an insertBefore() method but no insertAfter() method.
A javascript object can be stored in a browser's localStorage using - Answers JSON.stringify()
What are the additional reload options available via long click in Chrome? - Answers - Normal
Reload
- Hard Reload
- Empty Cache and Hard Reload
DevTools must be open to access these options.
This method creates a table body - Answers table.createTBody()
This method inserts a table row - Answers table.insertRow()
What are two ways to listen for events in js? - Answers - addEventListener()
- an onevent handler (onclick, onmouseup, etc.)
What are the two phases of event propagation in modern browsers? - Answers - bubbling (goes
from target to outermost ancestor)
- capturing (goes from outermost ancestor to target)
How is a custom event created and dispatched? - Answers 1. CustomEvent() to create
2. dispatchEvent() to dispatch
ex:
, const myEvent = new customEvent(
What objects can addEventListener() target? - Answers Any object that supports events,
including Element, Document, and Window
What parameters can be passed to addEventListener()? - Answers - an options object
- useCapture (true or false)
What are some benefits to using addEventListener()? - Answers - can use multiple handlers for
one event
- allows controlling phase (bubbling/capturing) when activated
What does the target DOM event property refer to? - Answers the element that triggered an
event
What does the currentTarget DOM event property refer to? - Answers The element where an
event listener is attached (could be parent to the element clicked)
What do the clientX and clientY DOM event properties refer to? - Answers the x and y
coordinates of a mouse click
Give an example of registering an onevent handler in js (i.e., not html) - Answers
document.getElementById('eltId').onchange = function(event) {// code here}
How can an element's onclick handler be called programmatically? - Answers elt.onclick(),
where elt is the element
Non-element objects do not support event handlers (T/F) - Answers False. window, document,
XMLHttpRequest and others support onevent handlers
What are the six fundamental DOM data types? - Answers - Document
- Node
- Element
- NodeList (array of elements, querySelectorAll())
- Attribute
- NamedNodeMap (accessible by name or index)
What method can be used to programmatically scroll to specific x,y coordinates in the
document? - Answers scrollTo()
How can elements be retrieved by class or tag name? - Answers - getElementsByClassName()