JavaScript MCQs

30 MCQs  — Web Development MCQs  (Page 3 of 3)

What is TypeScript?
A new browser engine
A server-side database
A typed superset of JavaScript that compiles (transpiles) to plain JavaScript
A CSS framework
What does document.querySelectorAll('.temp') return?
A live HTMLCollection
A static NodeList of all the matching elements
An array of strings
Only the first matching element
What is the difference between innerHTML and textContent?
textContent parses HTML
innerHTML parses its value as HTML (an XSS risk with untrusted data); textContent treats it as plain text
innerHTML escapes all tags
They are identical
What does the spread copy const b = [...a]; do when a contains objects?
It makes a deep copy of everything
It makes a shallow copy: a new array, but the same object references inside it
It makes b a reference to a
It copies only the first element
What is 'event delegation'?
Removing all listeners
Assigning events to another developer
Attaching one listener to a parent element and handling events from its children through bubbling, using event.target
Firing events on a timer
What does Array.prototype.map() return?
undefined
A single accumulated value
The original array, modified in place
A new array with the callback's result for each element; the original array is unchanged
Which statement about Node.js is correct?
It is a JavaScript runtime built on V8 that uses an event-driven, non-blocking I/O model, mainly for server-side code
It is a browser
It is a front-end CSS framework
It runs only in Chrome