๐ŸŒ The Odin Project ยท subject

The Odin Project JavaScript Syllabus

The JavaScript syllabus for The Odin Project in full: 8 chapters and 30 topics, every one listed below, plus 50 JavaScript flashcards with answers.

8Chapters
30Topics
50Flashcards

JavaScript syllabus: all 8 chapters

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

  1. Organizing Your JavaScript Code

    7 topics
    • Organizing Code with Objects
    • Object Constructors
    • Factory Functions and the Module Pattern
    • Classes
    • ES6 Modules
    • OOP Principles
    • Projects
  2. Build Tools & npm

    4 topics
    • npm
    • Webpack
    • Project: Restaurant Page
    • JSON
  3. JavaScript in the Real World

    3 topics
    • Linting
    • Form Validation with JavaScript
    • ECMAScript
  4. Asynchronous JavaScript and APIs

    4 topics
    • Asynchronous Code
    • Working with APIs
    • Async and Await
    • Project: Weather App
  5. Testing JavaScript

    3 topics
    • Testing Basics
    • Project: Testing Practice
    • More Testing
  6. A Bit of Computer Science

    4 topics
    • A Very Brief Intro to CS
    • Recursion
    • Complexity Analysis
    • Data Structures & Algorithms
  7. Intermediate Git

    3 topics
    • A Deeper Look at Git
    • Working with Remotes
    • Using Git in the Real World
  8. Finishing Up with JavaScript

    2 topics
    • Project: Battleship
    • Conclusion

The Odin Project JavaScript flashcards โ€” 50 questions with answers

  1. In JavaScript, what is an object literal and what is its basic syntax?

    An object literal is a way to create an object directly using curly braces containing comma-separated key: value pairs, e.g. const myObject = { property: 'Value!', otherProperty: 77, "obnoxious property": function() {} }. It creates a single object without needing a constructor or class.

  2. What is the difference between dot notation and bracket notation for accessing object properties, and when must you use bracket notation?

    Dot notation (obj.property) is cleaner but only works with valid identifier names known at write time. Bracket notation (obj["property"]) is required when the key contains spaces or special characters, or when the key is stored in a variable, e.g. obj[variable].

  3. What is an object constructor in JavaScript?

    A regular function written to be called with the new keyword that creates and initializes objects, conventionally named with a capital letter, e.g. function Player(name, marker) { this.name = name; this.marker = marker; }. Calling new Player('steve', 'X') returns a new Player object.

  4. What four things happen when a function is called with the new keyword?

    1) A new empty object is created; 2) the object's prototype is set to the constructor's .prototype property; 3) the constructor runs with this bound to the new object (initializing properties); 4) the new object is returned automatically (unless the constructor explicitly returns another object).

  5. What is the prototype of a JavaScript object?

    Another object that the original object inherits from: the original object gets access to all of the prototype's properties and methods. Every object has a prototype (accessible via Object.getPrototypeOf()), and objects made by a constructor inherit from Constructor.prototype.

  6. Describe how the prototype chain works when you access a property on an object.

    JavaScript first looks for the property on the object itself; if not found, it looks on the object's prototype, then on that prototype's prototype, and so on up the chain until it reaches Object.prototype (whose prototype is null). If the property is never found, undefined is returned.

  7. Why should methods be defined on Constructor.prototype instead of inside the constructor function itself?

    Methods on the prototype are created once and shared by every instance via the prototype chain, saving memory and allowing central updates. Methods defined inside the constructor are duplicated on every instance created.

  8. What is a factory function in JavaScript?

    A plain function that creates and returns a new object each time it is called, without using the new keyword, e.g. function createUser(name) { const discordName = '@' + name; return { name, discordName }; }. It often uses closures to keep some variables private.

  9. Compare factory functions with object constructors.

    Factories are called like normal functions (no new) so they can't silently fail when new is forgotten, and they enable true private variables via closure. Constructors use new and prototypes, so instances share methods (more memory-efficient) and work with instanceof; factory-made objects don't link to a shared prototype by default and instanceof won't identify them.

  10. What is a closure in JavaScript?

    A closure is the combination of a function and the surrounding lexical environment in which it was declared: the function retains access to variables from its outer scope even after that outer function has finished executing.

  11. How do factory functions create private variables and functions?

    Variables declared inside the factory but not included in the returned object are inaccessible from outside; only the returned methods (closures) can read or change them. Example: a counter factory returning { increment, getCount } keeps the count variable private and exposes it only through those methods.

  12. What is an IIFE and how does it relate to the module pattern?

    An IIFE (Immediately Invoked Function Expression) is a function wrapped in parentheses and called immediately: (function() { ... })(). The module pattern wraps a factory function in an IIFE so it runs once and returns a single object exposing public methods while keeping internal state private โ€” creating a one-off encapsulated module (namespace).

  13. What two main problems does wrapping code in modules/objects solve (namespacing)?

    It prevents naming collisions by grouping related variables and functions under one object (a namespace), and it encapsulates related functionality so internal details are hidden and the global scope is not polluted with many loose variables and functions.

  14. What are ES6 classes 'syntactic sugar' for in JavaScript?

    Classes are primarily syntactic sugar over JavaScript's existing prototype-based constructor functions: class methods are placed on the class's prototype and instances are still linked via the prototype chain. (They add real differences too: classes must be called with new, are not hoisted like function declarations, and their bodies run in strict mode.)

  15. What is the role of the constructor method inside a JavaScript class?

    constructor is the special method that runs automatically when a new instance is created with new; it receives the arguments passed to the class and initializes the instance's own properties (e.g. this.name = name). A class can have at most one constructor.

  16. How do extends and super work in JavaScript class inheritance?

    extends makes one class inherit from another (subclass gets the parent's methods via the prototype chain). Inside the subclass constructor, super(args) must be called before using this โ€” it runs the parent constructor to initialize inherited properties; super.method() calls a parent method.

  17. What does the static keyword do in a JavaScript class?

    static defines a property or method on the class itself rather than on instances. It is called as ClassName.method() and is typically used for utility functions or shared data, e.g. Date.now() or a static counter of created instances.

  18. How do you declare private fields and methods in a JavaScript class, and what do they guarantee?

    Prefix the name with # (e.g. #balance, #calculate()) and declare fields in the class body. Private members can only be accessed from inside the class; accessing #field from outside throws a syntax error, giving true encapsulation.

  19. What are named exports and default exports in ES6 modules, and how do their import syntaxes differ?

    Named exports: export const foo = ...; imported with matching names in braces: import { foo } from './module.js'. Default export: export default value; one per module, imported with any chosen name and no braces: import myName from './module.js'. A module can combine one default with many named exports.

  20. How do you enable ES6 modules in the browser, and what special behaviors do module scripts have?

    Use <script type="module" src="main.js"></script>. Module scripts have their own top-level scope (nothing leaks to the global scope), run in strict mode automatically, are deferred by default, and can use import/export statements.

Show the other 30 JavaScript flashcards
  1. Compare ES6 modules (ESM) with CommonJS modules.

    ESM uses import/export, is the official JavaScript standard, works natively in browsers and modern Node, and is statically analyzable (imports resolved at parse time, enabling tree shaking). CommonJS uses require()/module.exports, loads modules synchronously at runtime, and is the traditional Node.js system.

  2. What are the four pillars (core principles) of object-oriented programming?

    Encapsulation (bundling data with methods and hiding internal state), Abstraction (exposing a simple interface while hiding complexity), Inheritance (deriving new classes from existing ones to reuse behavior), and Polymorphism (objects of different types responding to the same method call in their own way).

  3. Define encapsulation in OOP and give a JavaScript example of achieving it.

    Encapsulation means bundling data and the methods that operate on it into one unit while restricting direct outside access to internal state. In JavaScript it is achieved with closures in factory functions/the module pattern, or with # private class fields, exposing only a public interface.

  4. What is the Single Responsibility Principle (the 'S' in SOLID)?

    A class, module, or function should have only one responsibility โ€” one reason to change. For example, DOM-manipulation code should be separated from game logic, so changing how results are displayed does not require touching the code that computes them.

  5. In software design, what is 'tightly coupled' code, and why is 'composition over inheritance' recommended?

    Tightly coupled code is code where modules depend heavily on each other's internals, so changing one forces changes in others; loose coupling keeps modules independent behind small interfaces. Composition (building objects from smaller capabilities โ€” 'has-a') is favored over deep inheritance ('is-a') because rigid inheritance hierarchies force subclasses to inherit unneeded behavior and are hard to restructure.

  6. What is npm?

    npm is the default package manager for Node.js: a command-line tool (npm install, npm init, npm run) plus the world's largest online registry of JavaScript packages, used to install, manage, and publish project dependencies.

  7. What is the purpose of the package.json file?

    It is the manifest of a Node/JavaScript project: it records the project's name, version, scripts (custom commands run with npm run), and its dependencies and devDependencies with version ranges, so anyone can recreate the project's environment with npm install.

  8. What is the difference between dependencies and devDependencies in package.json?

    dependencies are packages the application needs at runtime in production (e.g. lodash). devDependencies (installed with npm install --save-dev) are only needed during development and building โ€” e.g. webpack, ESLint, Prettier โ€” and are not required by the shipped code.

  9. What is Webpack and what problem does it solve?

    Webpack is a module bundler: starting from an entry point (e.g. src/index.js), it builds a dependency graph of all imported modules and assets (JS, CSS, images, fonts) and bundles them into optimized output files (in dist/) for the browser โ€” reducing HTTP requests and letting you develop with modules while shipping processed static files.

  10. What are loaders in Webpack and which two are needed to bundle CSS?

    Loaders are rules that teach Webpack to process non-JavaScript files before bundling. For CSS you need css-loader (reads the CSS file and resolves its imports/urls into JS) and style-loader (injects that CSS into the page via <style> tags); they are listed as use: ['style-loader', 'css-loader'] and applied right-to-left.

  11. What are Webpack plugins, and what does HtmlWebpackPlugin do?

    Plugins hook into Webpack's build process to perform broader tasks than per-file loaders. HtmlWebpackPlugin automatically generates the dist HTML file (optionally from a template like src/template.html) with <script> tags for the output bundles already injected, so you never hand-edit dist files.

  12. In Webpack, what is the difference between 'development' and 'production' mode, and what does webpack-dev-server provide?

    mode: 'development' builds faster with better debugging info (e.g. source maps friendly, unminified), while mode: 'production' optimizes and minifies output for deployment. webpack-dev-server serves the site locally, watches source files, and automatically rebuilds and reloads the browser on every change.

  13. In The Odin Project's Restaurant Page project, how is the page content structured and rendered?

    The HTML contains essentially a single empty <div id="content">; all page content is generated dynamically with JavaScript DOM methods (createElement, appendChild). Each tab (Home, Menu, Contact) lives in its own ES6 module exporting a render function, and nav button click listeners clear #content and load the selected tab's content โ€” the whole project is bundled with Webpack.

  14. What is JSON and what is it used for?

    JSON (JavaScript Object Notation) is a lightweight, language-independent text format for storing and exchanging structured data, based on JavaScript object syntax. It is the standard format for sending data between web servers/APIs and clients.

  15. What do JSON.parse() and JSON.stringify() do?

    JSON.parse(text) converts a JSON string into a live JavaScript object/value (used on data received from a server). JSON.stringify(value) converts a JavaScript object/value into a JSON string (used to send data or store it, e.g. in localStorage). The conversions are called deserialization and serialization.

  16. List the key syntax rules of JSON that differ from JavaScript object literals.

    All property names must be double-quoted strings; strings use double quotes only; values may only be strings, numbers, booleans, null, arrays, or objects (no functions, undefined, comments, or trailing commas). A common bug source is invalid JSON โ€” validators (JSON formatters/linters) catch such errors.

  17. What is a linter, and what does ESLint do for JavaScript?

    A linter is a tool that statically analyzes source code against a set of rules to flag errors, bugs, and style/code-quality problems before the code runs. ESLint is the standard JavaScript linter: it catches issues like unused variables, undefined references, and rule violations, and can auto-fix many of them.

  18. What is the difference between ESLint and Prettier, and how are they used together?

    ESLint checks code quality (potential bugs, bad patterns), while Prettier is an opinionated code formatter that only handles style โ€” indentation, quotes, line length, semicolons. They are used together, typically with a config (e.g. eslint-config-prettier) that disables ESLint's formatting rules so the two tools don't conflict.

  19. What key methods and hooks does the Constraint Validation API provide for JavaScript form validation?

    checkValidity() returns true/false for a field or whole form; reportValidity() checks and shows browser messages; setCustomValidity(message) sets a custom error (empty string means valid); each field exposes a validity (ValidityState) object and a validationMessage; invalid fields fire an 'invalid' event and match the :invalid CSS pseudo-class.

  20. Name common ValidityState properties used to detect why a form field is invalid.

    valueMissing (required field empty), typeMismatch (value doesn't match input type, e.g. email), patternMismatch (fails the pattern regex attribute), tooShort/tooLong (violates minlength/maxlength), rangeUnderflow/rangeOverflow (outside min/max), and valid (true when all constraints pass).

  21. What is ECMAScript, who maintains it, and how are versions released? What is ES6 also known as?

    ECMAScript is the standardized specification that JavaScript implements, maintained by the TC39 committee under Ecma International (standard ECMA-262). ES6 is the landmark 2015 edition, officially ES2015 (introducing let/const, classes, modules, arrow functions, promises); since then a new edition is released every year (ES2016, ES2017, ...).

  22. Why does JavaScript need asynchronous code, and what is the difference between synchronous and asynchronous execution?

    JavaScript runs on a single thread: synchronous code executes line by line, and a slow operation (network request, timer, file read) would block everything, freezing the page. Asynchronous code starts such operations, lets the rest of the program continue, and handles the result later via callbacks, promises, or async/await.

  23. What is a callback function, and what problem is 'callback hell'?

    A callback is a function passed as an argument to another function to be executed later (e.g. after an event or async operation completes). Callback hell (the 'pyramid of doom') is deeply nested callbacks from sequential async steps, making code hard to read, reason about, and handle errors in โ€” a key motivation for promises.

  24. What is a Promise in JavaScript, and what are its three possible states?

    A Promise is an object representing the eventual completion or failure of an asynchronous operation โ€” a placeholder for a value not yet available. Its states are: pending (initial, operation in progress), fulfilled (completed successfully with a value), and rejected (failed with an error/reason). Once settled, its state cannot change.

  25. How do .then(), .catch(), and .finally() work with promises?

    .then(onFulfilled) registers a handler for the fulfilled value and returns a new promise, so calls can be chained to run async steps in sequence (avoiding callback hell); .catch(onRejected) handles a rejection from any earlier step in the chain; .finally() runs regardless of outcome (e.g. to hide a loading spinner).

  26. How does the fetch() API work for making HTTP requests?

    fetch(url, options) returns a promise that resolves to a Response object once headers arrive. The promise rejects only on network failure โ€” HTTP errors like 404 still fulfill, so you must check response.ok/response.status. To read the body you call a method like response.json(), which itself returns a promise with the parsed data.

  27. When working with third-party web APIs, what are API keys and CORS?

    An API key is a unique identifier appended to requests (often as a query parameter) so the provider can identify the caller, apply rate limits, and control usage. CORS (Cross-Origin Resource Sharing) is the browser mechanism governing requests to a different origin; the server must allow it, and fetch can specify { mode: 'cors' }.

  28. What does the async keyword do when placed before a function?

    It makes the function always return a promise: a returned value becomes the promise's fulfilled value, and a thrown error becomes its rejection. It also enables use of the await keyword inside the function body, allowing asynchronous code to be written in a synchronous style โ€” it is syntactic sugar over promises.

  29. What does the await keyword do, and how are errors handled in async/await code?

    await pauses execution of the async function until the promise settles, then returns the fulfilled value (without blocking the main thread); if the promise rejects, await throws that error. Errors are handled by wrapping awaited calls in try { ... } catch (err) { ... } (with optional finally), or with .catch() on the returned promise.

  30. In The Odin Project's Weather App project, what is the core data flow for displaying weather?

    Take a user's location input, fetch() the weather API's endpoint URL containing the location and your API key, await/parse the response with response.json(), extract only the needed fields into your own data object (a processing function), then render them to the DOM โ€” while showing a loading indicator during the fetch and handling errors (e.g. invalid location) with catch/try-catch.

The Odin Project JavaScript FAQ

What is in the The Odin Project JavaScript syllabus?

The Odin Project JavaScript is split into 8 chapters: Organizing Your JavaScript Code, Build Tools & npm, JavaScript in the Real World, Asynchronous JavaScript and APIs, Testing JavaScript, A Bit of Computer Science, Intermediate Git and Finishing Up with JavaScript. Together they contain 30 topics.

How many chapters are in The Odin Project JavaScript?

8 chapters, containing 30 topics. The largest chapter is Organizing Your JavaScript Code, with 7 topics.

Are there flashcards for The Odin Project JavaScript?

Yes โ€” a 50-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.