HomeCode HereJavaScript final quiz JavaScript final quiz Admin 1 min read Updated November 16, 2026 Ten mixed questions on events, async code, modules, accessibility and the capstone. JavaScript JavaScript final quiz 10 questions, instant feedback Question 1 of 10 Which statement about JavaScript in the browser is true? A It runs on the server only B It runs in the page and can update the DOM C It replaces HTML D It requires a database The browser runs JavaScript with access to the DOM, events and browser APIs. The same language also runs on servers via Node. Question 2 of 10 Why should a script that reads the DOM be loaded with defer or placed at the end of body? A To make it smaller B So the elements exist before the script queries them C To enable strict mode D To avoid CSS Scripts in the head run before the body is parsed. defer waits until parsing finishes, so querySelector finds the elements. Question 3 of 10 A form handler throws on a missing field. What is the best response? A Ignore it B Show a specific message near the field and keep focus in the form C Reload the page D Disable the form Specific, visible feedback near the field is usable and announced. Reloading loses everything the person typed. Question 4 of 10 Which is the safest way to insert user-provided text? A innerHTML B textContent C document.write D eval textContent cannot introduce markup or scripts. innerHTML with untrusted text is a cross-site scripting risk. Question 5 of 10 What does event delegation rely on? A Event bubbling B CSS specificity C Promises D Local storage A listener on a parent receives events from children as they bubble, so one handler covers dynamically added items. Question 6 of 10 Which code reads a stored object safely? A JSON.parse(localStorage.getItem('tasks') || '[]') B localStorage.getItem('tasks').items C JSON.stringify(localStorage.getItem('tasks')) D localStorage.tasks[0] Storage returns a string or null. Parsing with a fallback array handles the first run, and a try/catch handles corrupted data. Question 7 of 10 Why wrap JSON.parse in try...catch when reading saved data? A Parsing is slow B The stored string may be corrupted or edited C JSON.parse always throws D It improves performance Saved data can be truncated or hand-edited. A parse error should not break the whole app. Question 8 of 10 What is the main benefit of splitting code into modules? A Smaller HTML B Explicit dependencies and testable units C Faster fonts D No need for functions Imports and exports make dependencies visible, and each module can be tested or replaced on its own. Question 9 of 10 Which practice keeps a to-do app usable with a keyboard? A Clickable divs for every action B Real buttons, labels and visible focus C Removing outlines D Auto-submitting on every keypress Native controls handle Enter, Space and focus. Visible focus is required for anyone navigating without a mouse. Question 10 of 10 When should state be written to localStorage in a to-do app? A Only on page unload B After every change that must survive a reload C Never D Only on the first visit Saving after each successful change means a crash or closed tab loses nothing. Saving only on unload is unreliable. Check my answers Try again Your answers stay in this browser. Nothing is sent to a server. More quizzes JavaScript async and data quiz 9 questions Modern JavaScript quiz 9 questions JavaScript functions quiz Coming soon All quizzes