🌍 Front-end Web Development · subject

Front-end Web Development JavaScript Syllabus

The JavaScript syllabus for Front-end Web Development in full: 4 chapters and 12 topics, every one listed below, plus 56 JavaScript flashcards with answers.

4Chapters
12Topics
56Flashcards

JavaScript syllabus: all 4 chapters

Expand any chapter to see its topics and sub-topics.

  1. Basics

    3 topics
    • Syntax and Operators
    • Data Types
    • Control Structures
  2. Functions

    3 topics
    • Function Declaration
    • Arrow Functions
    • Higher-Order Functions
  3. DOM Manipulation

    3 topics
    • Selecting Elements
    • Event Handling
    • Modifying Elements
  4. Advanced

    3 topics
    • Asynchronous JavaScript
    • Promises
    • Async/Await

Front-end Web Development JavaScript flashcards — 56 questions with answers

  1. What are the three ways to declare a variable in modern JavaScript, and how does each handle reassignment and scope?

    $var$ (function-scoped, reassignable, hoisted), $let$ (block-scoped, reassignable), and $const$ (block-scoped, cannot be reassigned). $let$ and $const$ are not initialized until their declaration (temporal dead zone).

  2. What is the difference between the equality operators $==$ and $===$ in JavaScript?

    $==$ is loose equality: it performs type coercion before comparing. $===$ is strict equality: it compares both value and type with no coercion. $===$ is generally preferred.

  3. What does the ternary (conditional) operator look like and what does it do?

    $condition\ ?\ exprIfTrue : exprIfFalse$. It evaluates the condition and returns the first expression if truthy, otherwise the second. It is the only operator that takes three operands.

  4. What is the difference between the logical AND operator ($\&\&$) and the nullish coalescing operator ($??$)?

    $\&\&$ returns the right operand only if the left is truthy. $??$ returns the right operand only if the left is $null$ or $undefined$ (it does NOT trigger on other falsy values like $0$ or empty string).

  5. In JavaScript, what is the result of the expression $5\ \%\ 2$, and what does the operator do?

    The result is $1$. The $\%$ (modulo / remainder) operator returns the remainder of integer division of its operands.

  6. What is the difference between the postfix ($x{++}$) and prefix ($+{+}x$) increment operators?

    Both increase $x$ by $1$. Prefix $+{+}x$ increments first then returns the new value; postfix $x{++}$ returns the original value first then increments.

  7. List the seven primitive data types in JavaScript.

    $String$, $Number$, $Boolean$, $undefined$, $null$, $BigInt$, and $Symbol$. Everything else (objects, arrays, functions) is of type $Object$.

  8. What does the $typeof$ operator return for $null$, and why is this notable?

    $typeof\ null$ returns $"object"$. This is a long-standing bug in JavaScript kept for backward compatibility; $null$ is actually a primitive.

  9. What is the difference between $undefined$ and $null$ in JavaScript?

    $undefined$ means a variable has been declared but not assigned a value (the default absence of value). $null$ is an intentional, explicit assignment representing 'no value'. $typeof\ undefined$ is $"undefined"$; $typeof\ null$ is $"object"$.

  10. What is the difference between a primitive type and a reference type regarding how they are copied?

    Primitives are copied by value (each variable holds its own copy). Reference types (objects, arrays, functions) are copied by reference (variables point to the same underlying object in memory).

  11. What special numeric value does $0/0$ produce, and how do you reliably test for it?

    It produces $NaN$ (Not-a-Number). Since $NaN \neq NaN$, you must test it with $Number.isNaN(x)$ rather than $x === NaN$.

  12. Which values are 'falsy' in JavaScript?

    There are six (plus NaN): $false$, $0$, empty string $""$, $null$, $undefined$, and $NaN$. ($0n$/BigInt zero is also falsy.) All other values are truthy.

  13. What is the difference between an $if/else\ if/else$ chain and a $switch$ statement?

    An $if/else\ if$ chain evaluates arbitrary boolean conditions sequentially. A $switch$ compares one expression against multiple $case$ values using strict equality ($===$), and falls through unless $break$ is used.

  14. What is the difference between a $for$ loop, a $for...of$ loop, and a $for...in$ loop?

    $for$ uses an explicit counter. $for...of$ iterates over the values of an iterable (arrays, strings). $for...in$ iterates over the enumerable keys/property names of an object.

  15. What is the difference between a $while$ loop and a $do...while$ loop?

    A $while$ loop checks the condition before each iteration, so the body may run zero times. A $do...while$ loop runs the body once before checking the condition, guaranteeing at least one execution.

  16. What do the $break$ and $continue$ statements do inside a loop?

    $break$ immediately exits the entire loop. $continue$ skips the rest of the current iteration and proceeds to the next one.

  17. Write a standard JavaScript function declaration that returns the square of $x$.

    $$function\ square(x)\ \{\ return\ x\ *\ x;\ \}$$ A function declaration is hoisted, so it can be called before it appears in the code.

  18. What is the difference between a function declaration and a function expression regarding hoisting?

    A function declaration ($function\ foo()\{\}$) is fully hoisted and callable before its definition. A function expression ($const\ foo = function()\{\}$) is not; only the variable is hoisted, so calling it early throws an error.

  19. What does a function return if it has no explicit $return$ statement?

    It returns $undefined$.

  20. What are default parameters and how are they written in a function declaration?

    Default parameters provide a fallback value when an argument is omitted or $undefined$: $$function\ greet(name = "Guest")\ \{\ ...\ \}$$ Calling $greet()$ uses $"Guest"$.

Show the other 36 JavaScript flashcards
  1. What is the rest parameter syntax and what does it produce?

    The rest parameter $...args$ collects all remaining arguments into a real array: $$function\ sum(...nums)\ \{\ ...\ \}$$ It must be the last parameter.

  2. Write an arrow function that returns the sum of $a$ and $b$, using the most concise form.

    $$const\ add = (a, b) \Rightarrow a + b;$$ With a single expression body, the braces and the $return$ keyword are omitted (implicit return).

  3. How does an arrow function handle the $this$ keyword differently from a regular function?

    An arrow function does not have its own $this$; it lexically inherits $this$ from the enclosing scope. A regular function's $this$ is determined by how it is called.

  4. How do you write an arrow function that takes a single parameter, and one that takes no parameters?

    Single parameter (parentheses optional): $x \Rightarrow x * 2$. No parameters (empty parentheses required): $() \Rightarrow 42$.

  5. How do you return an object literal directly from a concise arrow function?

    Wrap the object in parentheses so it is not parsed as a function body: $$const\ make = () \Rightarrow (\{\ id: 1\ \});$$

  6. Name things arrow functions lack that regular functions have.

    Arrow functions have no own $this$, no $arguments$ object, no $super$, and cannot be used as constructors (no $new$). They also have no $prototype$ property.

  7. What is a higher-order function?

    A higher-order function is a function that either takes one or more functions as arguments, returns a function, or both. Examples include $map$, $filter$, and $reduce$.

  8. What does $Array.prototype.map()$ do and what does it return?

    $map()$ calls a callback on every element and returns a NEW array of the same length containing the transformed results. It does not mutate the original array.

  9. What is the difference between $map()$ and $forEach()$?

    $map()$ returns a new array of transformed values and is used for transformation. $forEach()$ returns $undefined$ and is used purely for side effects (it does not build a new array).

  10. What does $Array.prototype.filter()$ return?

    It returns a new array containing only the elements for which the callback returns a truthy value. Its length is less than or equal to the original.

  11. Explain $Array.prototype.reduce()$ and its callback signature.

    $reduce()$ reduces an array to a single value by applying a callback $(accumulator, currentValue, index, array)$ across all elements, threading the accumulator: $$[1,2,3].reduce((acc, x) \Rightarrow acc + x, 0) = 6$$

  12. What is a callback function?

    A callback is a function passed as an argument to another function, to be invoked (called back) later — either synchronously (e.g., in $map$) or asynchronously (e.g., after an event or timer).

  13. What is the difference between $find()$ and $filter()$?

    $find()$ returns the first single element matching the predicate (or $undefined$). $filter()$ returns a new array of all matching elements.

  14. Which DOM method selects a single element by its $id$ attribute, and what does it return if not found?

    $document.getElementById("myId")$. It returns the element, or $null$ if no element with that id exists.

  15. What is the difference between $querySelector()$ and $querySelectorAll()$?

    $querySelector(selector)$ returns the FIRST element matching a CSS selector (or $null$). $querySelectorAll(selector)$ returns a static $NodeList$ of ALL matching elements.

  16. What is the key difference between $getElementsByClassName()$ and $querySelectorAll()$ regarding the collection returned?

    $getElementsByClassName()$ returns a LIVE $HTMLCollection$ that updates as the DOM changes. $querySelectorAll()$ returns a STATIC $NodeList$ that does not update after creation.

  17. How do you select all elements with the class $card$ using a CSS-selector-based method?

    $document.querySelectorAll(".card")$. The leading dot denotes a class selector; for an id you would use $"#card"$.

  18. Why can't you call array methods like $map()$ directly on the result of $querySelectorAll()$, and how do you fix it?

    It returns a $NodeList$, not a true array. Convert it first with $Array.from(nodeList)$ or the spread $[...nodeList]$ before using $map$, $filter$, etc.

  19. What is the standard method to attach an event handler to an element, and what is an advantage of it?

    $element.addEventListener(type, listener, options)$ — e.g., $element.addEventListener("click", handler)$. It can attach multiple handlers for the same event type without overwriting.

  20. What is event bubbling in the DOM?

    Event bubbling is the propagation phase where an event triggered on an element fires first on that target, then propagates upward through each ancestor toward the document root.

  21. What is the difference between $event.preventDefault()$ and $event.stopPropagation()$?

    $preventDefault()$ cancels the browser's default action (e.g., following a link or submitting a form). $stopPropagation()$ halts the event from bubbling/capturing further to other elements.

  22. What is event delegation and why is it useful?

    Event delegation attaches a single listener to a common parent and uses $event.target$ to determine which child triggered it. It is efficient and automatically handles dynamically added children.

  23. What is the difference between $event.target$ and $event.currentTarget$?

    $event.target$ is the actual element that originated the event. $event.currentTarget$ is the element whose listener is currently executing (the one $addEventListener$ was called on).

  24. What is the difference between an element's $textContent$ and $innerHTML$ properties?

    $textContent$ gets/sets only plain text and treats input as literal text. $innerHTML$ gets/sets HTML markup, parsing tags into DOM nodes (which carries XSS risk with untrusted input).

  25. How do you add, remove, and toggle a CSS class on an element?

    Use the $classList$ API: $el.classList.add("x")$, $el.classList.remove("x")$, and $el.classList.toggle("x")$. You can also test with $el.classList.contains("x")$.

  26. What is the difference between setting a style via $element.style.color$ and changing a class?

    $element.style.color$ sets an inline style on that single element only. Changing a class applies all rules defined for that class in the stylesheet, which is preferred for separating concerns.

  27. What is the difference between $setAttribute()$ and directly setting a property like $element.value$?

    $setAttribute("value", x)$ changes the HTML attribute (the initial/default). Setting $element.value$ changes the live DOM property (current state). They can diverge after user interaction.

  28. What is the JavaScript event loop, and why is single-threaded JS still non-blocking?

    The event loop continuously checks the call stack; when it is empty it pushes queued callbacks (from the task/microtask queues) onto it. Async operations are offloaded to the environment, so the single thread is never blocked waiting.

  29. What is a Promise in JavaScript and what three states can it be in?

    A Promise is an object representing the eventual result of an asynchronous operation. Its three states are: $pending$ (initial), $fulfilled$ (resolved with a value), and $rejected$ (failed with a reason). Once settled it is immutable.

  30. What is the difference between the microtask queue and the macrotask queue regarding execution order?

    Microtasks (e.g., Promise $.then$ callbacks, $queueMicrotask$) run after current synchronous code and BEFORE the next macrotask. Macrotasks (e.g., $setTimeout$, DOM events) run one per event-loop tick, with all microtasks drained between them.

  31. How do $Promise.all()$ and $Promise.race()$ differ?

    $Promise.all([...])$ resolves when ALL promises fulfill (returning an array of results) and rejects as soon as any one rejects. $Promise.race([...])$ settles as soon as the FIRST promise settles (fulfilled or rejected).

  32. How do you handle a rejected Promise, and what method runs regardless of outcome?

    Chain $.catch(err \Rightarrow ...)$ to handle rejection, and $.finally(() \Rightarrow ...)$ to run cleanup code whether the promise fulfilled or rejected.

  33. What does the $async$ keyword do to a function's return value?

    An $async$ function always returns a Promise. A returned non-promise value is automatically wrapped in a resolved Promise, and a thrown error becomes a rejected Promise.

  34. What does the $await$ keyword do, and where can it be used?

    $await$ pauses execution of an $async$ function until the awaited Promise settles, then returns its fulfilled value (or throws its rejection). It can only be used inside an $async$ function or at the top level of a module.

  35. How do you handle errors when using $async/await$?

    Wrap the awaited calls in a $try...catch$ block; a rejected awaited Promise throws an error that $catch$ intercepts. Optionally add a $finally$ block for cleanup.

  36. What is the difference between awaiting two promises sequentially versus running them concurrently with $Promise.all$?

    Sequential ($const\ a = await\ p1; const\ b = await\ p2;$) waits for each in turn, so total time is the sum. $await\ Promise.all([p1, p2])$ starts both immediately and waits once, so total time is the maximum of the two.

Front-end Web Development JavaScript FAQ

What is in the Front-end Web Development JavaScript syllabus?

Front-end Web Development JavaScript is split into 4 chapters: Basics, Functions, DOM Manipulation and Advanced. Together they contain 12 topics.

How many chapters are in Front-end Web Development JavaScript?

4 chapters, containing 12 topics. The largest chapter is Basics, with 3 topics.

Are there flashcards for Front-end Web Development JavaScript?

Yes — a 56-card JavaScript deck, printed in full in the flashcards section of this page and available in the Examius app with spaced repetition. The free plan covers one exam of your choice, including its flashcards; Examius Pro, a one-time purchase, unlocks every other exam and deck.