Skip to content

Latest commit

 

History

History
130 lines (110 loc) · 8.89 KB

QUIZZES.md

File metadata and controls

130 lines (110 loc) · 8.89 KB

JavaScript phase review

Answer the eight questions after each phase before reading the answers. If you cannot explain an answer, edit the matching lesson example and observe the result.

Phase 1: foundations

Lesson Question Answer
01 Is document part of ECMAScript or a browser API? It is a browser API.
02 What does a breakpoint let you inspect? Current variable values and control flow at a paused line.
03 Can a const object have a property changed? Yes; const prevents rebinding, not mutation of the object.
04 What does typeof null return? The string object, a historical behavior.
05 Is an empty array truthy? Yes.
06 Which fallback preserves zero: nullish coalescing or logical OR? Nullish coalescing.
07 Does trim change the original string? No; it returns a new string.
08 What type is an HTML input value? A string until converted.

Phase 2: control flow and functions

Lesson Question Answer
09 Why test both sides of a grade boundary? An off-by-one comparison often appears there.
10 What happens without break in a switch case? Execution can continue into the next case.
11 What keeps a while loop from running forever? A condition that eventually becomes false or an explicit break.
12 What does a function return when it has no return statement? undefined.
13 Why are pure functions easier to test? The result depends on inputs instead of hidden outside state.
14 What does a closure retain? Access to bindings from its lexical surroundings.
15 Where should an error be caught? Where code can recover or show useful feedback.
16 Why separate calculator logic from DOM code? Logic can be tested independently and reused.

Phase 3: collections and data

Lesson Question Answer
17 Does slice change its original array? No; it returns a new array.
18 Which method returns only matching items? filter.
19 Does assigning an object to another variable clone it? No; both variables reference the same object.
20 Is object spread a deep copy? No; nested objects remain shared.
21 Which collection stores unique values? Set.
22 Does formatting a date for another locale change the stored instant? No; only its presentation changes.
23 What do ^ and $ do in a regular expression? Anchor a match to the start and end.
24 Does Array.sort mutate the array? Yes; sort a copy when the original must remain unchanged.

Phase 4: browser and DOM

Lesson Question Answer
25 What does querySelector return for no match? null.
26 Which property safely displays user text without parsing HTML? textContent.
27 Why update an attribute as well as a CSS class? The attribute may communicate state or behavior beyond appearance.
28 What is the event object's currentTarget? The element whose listener is currently running.
29 Why listen to form submit rather than only button click? It also handles Enter-key submission.
30 Why use closest in a delegated listener? The event target may be a nested child of the action element.
31 What must be done with an interval when no longer needed? Clear it.
32 What should be the source of truth for a task list? Task data or state, from which the DOM is rendered.

Phase 5: asynchronous JavaScript

Lesson Question Answer
33 Does a zero-delay timeout interrupt synchronous code? No; it runs in a later task.
34 What does Promise.all do when one input rejects? Its returned promise rejects.
35 Does await block the entire browser page? No; it pauses the async function.
36 Can fetch fulfill with an HTTP 404 response? Yes; inspect response.ok or status.
37 What error name identifies a normal abort? AbortError.
38 What type of values does localStorage store? Strings.
39 What event helps update UI after Back or Forward? popstate.
40 What prevents an old response from replacing a newer selection? Cancellation or an explicit stale-result check.

Phase 6: modules and architecture

Lesson Question Answer
41 What does a module give each file? Its own scope and explicit imports or exports.
42 Why avoid circular module initialization? Values can be unavailable or confusing during initialization.
43 Can a closure keep private state between calls? Yes.
44 Where are class methods shared? On the prototype.
45 Does copying an array also clone nested objects? No.
46 What should happen after an action changes state? Render the affected UI from the new state.
47 What does package.json describe? Project metadata, scripts, and dependencies.
48 What matters more than a folder layout for architecture? Clear responsibilities and dependency direction.

Phase 7: quality and production

Lesson Question Answer
49 Which error should you inspect first? The first relevant error that explains the failing path.
50 What cases should a focused function test include? Normal, boundary, and failure or invalid cases.
51 Should aria-expanded reflect actual open state? Yes, always.
52 Is manual character replacement a general HTML sanitizer? No.
53 What should happen before performance optimization? Measure the user-relevant bottleneck.
54 Why prefer feature detection to browser-name checks? It tests the capability needed rather than guessing from identity.
55 What makes a review comment actionable? A specific issue, effect, and testable fix.
56 Where should deployment be smoke-tested? At the published URL.

Phase 8: advanced and senior practice

Lesson Question Answer
57 What does a generator yield? Iterator values one at a time.
58 Can UTF-8 byte length differ from string length? Yes, especially for non-ASCII text.
59 Can a Web Worker directly edit the DOM? No; it communicates with the main thread through messages.
60 Can an active interval keep running after its UI is removed? Yes, unless it is cleared.
61 Should every failed POST be automatically retried? No; a retry could duplicate an action.
62 What belongs in a component contract? Inputs, outputs, states, events, and accessibility behavior.
63 Which states make a data app more than a polished default screen? Loading, empty, error, cancelled or offline-like, and usable keyboard states.
64 What evidence supports a senior-level case study? Decisions, tests, measurements, feedback, fixes, and stated limits.

Advanced browser systems and architecture: lessons 65–81

Lesson Question Answer
65 What determines a normal function's this value? How the function is called; arrow functions capture this lexically.
66 Where is a class method usually stored? On the class prototype, shared by instances.
67 Why use a Symbol key? It provides a unique property key that avoids accidental name collisions.
68 What must a Proxy trap usually preserve? The target operation's invariants and intended behavior.
69 Why use WeakMap for private metadata? Its object keys do not stay alive only because they are keys in that map.
70 What does for await...of consume? An async iterable, requesting values as promises resolve.
71 What is backpressure? A way for a slower consumer to limit how quickly a producer supplies data.
72 Does shadow DOM make a component's data automatically secure? No; it scopes markup and styles, not authorization or secret data.
73 What does an IndexedDB transaction provide? A scoped set of database operations with completion or failure behavior.
74 What scope can a service worker control? Pages under its registered scope, subject to secure-origin and lifecycle rules.
75 Is WebSocket message delivery equivalent to an HTTP request? No; it is a persistent bidirectional connection with its own failure and reconnect handling.
76 Why use Intl formatters instead of hand-built date strings? Locale rules vary and the platform formatter handles those conventions.
77 Does a CSP replace safe DOM APIs? No; CSP is an additional policy boundary, not a substitute for safe coding.
78 What should guide a performance optimization? A measured bottleneck tied to user-visible cost.
79 What origin boundary does BroadcastChannel use? Same-origin contexts that join the same named channel.
80 Should a global error handler silently swallow an error? No; report useful diagnostics and preserve appropriate user feedback or failure behavior.
81 What makes an architecture review finding useful? Impact, reproduction evidence, a clear risk, and a testable next step.