🌍 ExpressJS · flashcards

ExpressJS Core Concepts of ExpressJS Flashcards

51 question-and-answer cards covering Core Concepts of ExpressJS as it is examined in ExpressJS. 24 of them are printed below, taken from across the deck — no signup, no paywall on the preview.

51Cards in deck
24Free preview
16Syllabus topics
~194Chars per answer
FreePrice

24 sample cards from the Core Concepts of ExpressJS deck

Sampled from the end of the deck, so these are different cards from the ones shown on the syllabus page.

  1. What is the req object in Express?

    The HTTP request object representing the incoming request; it exposes properties and methods for reading the request such as req.params, req.query, req.body, req.headers, req.method, req.path, and req.cookies.

  2. What do req.params, req.query, and req.body each contain?

    req.params — route/path parameters (:id); req.query — parsed URL query string parameters (?key=value); req.body — the parsed request payload (requires a body-parsing middleware like express.json()).

  3. How do you read a request header in Express?

    Using req.get('Header-Name') (case-insensitive) or the req.headers object, e.g. req.get('Content-Type') or req.headers['content-type'].

  4. What is the res object in Express?

    The HTTP response object used to build and send the reply to the client; it exposes methods like res.send(), res.json(), res.status(), res.redirect(), res.sendFile(), and res.set()/res.append().

  5. What is the difference between res.send() and res.json()?

    res.send() sends a response of various types (string, Buffer, object, array) and infers the Content-Type; res.json() explicitly serializes the argument to JSON and sets Content-Type to application/json. res.json() also correctly handles values like null.

  6. How do you set the HTTP status code of a response in Express?

    With res.status(code), which is chainable, e.g. res.status(404).send('Not Found') or res.status(201).json(data).

  7. What does res.redirect() do?

    It sends a redirect response to the client, setting the Location header and a 3xx status (302 by default). Example: res.redirect('/login') or res.redirect(301, '/new-url').

  8. How does Express handle different content types when receiving requests?

    By using the appropriate body-parsing middleware matched to the request's Content-Type: express.json() for application/json, express.urlencoded() for form data, express.text() for text/plain, and express.raw() for binary/Buffer bodies.

  9. How do you explicitly set the response Content-Type in Express?

    Using res.type('...') or res.set('Content-Type', '...'), e.g. res.type('html') or res.set('Content-Type', 'application/xml').

  10. What is content negotiation and how does res.format() support it?

    Content negotiation serves different representations based on the client's Accept header. res.format() lets you define handlers per content type, e.g. res.format({ 'text/html': ()=>..., 'application/json': ()=>... }), and Express picks the best match.

  11. List the main methods used to send responses in Express.

    res.send() (generic), res.json() (JSON), res.sendFile() (a file), res.render() (a view/template), res.redirect() (redirect), res.end() (end without data), and res.download() (prompt file download).

  12. Why can you only send one response per request in Express?

    Because a response method (res.send/json/end) ends the response and writes headers/body; calling another afterward triggers the 'Cannot set headers after they are sent to the client' error since the HTTP response is already committed.

  13. What does res.sendStatus() do?

    It sets the response HTTP status code and sends its standard message text as the body in one call, e.g. res.sendStatus(200) sends 'OK', res.sendStatus(404) sends 'Not Found'.

  14. What is Express's default (built-in) error handling behavior?

    Express ships with a built-in default error handler. Errors thrown in synchronous code or passed to next(err) are caught and by default sent to the client with a stack trace in development, and a generic message plus 500 status in production.

  15. How do you forward an error to Express's error-handling middleware?

    By passing the error to next(), i.e. next(err). Any truthy value passed to next() (other than the string 'route') tells Express to skip remaining normal middleware and invoke error-handling middleware.

  16. How does Express handle errors thrown in asynchronous code (e.g., in a Promise)?

    In Express 4, async errors are NOT caught automatically — you must catch them and call next(err) yourself (or use a wrapper). In Express 5, rejected promises returned from handlers are automatically forwarded to error middleware.

  17. What distinguishes an error-handling middleware function in Express?

    It has exactly four arguments: (err, req, res, next). Express identifies error handlers by this arity and only calls them when an error is passed to next().

  18. Write a basic custom error-handling middleware.

    app.use((err, req, res, next) => { console.error(err.stack); res.status(err.status || 500).json({ error: err.message }); }); It must be defined after all other app.use() and routes.

  19. Where must error-handling middleware be placed in the middleware stack?

    Last — after all other app.use() calls and route definitions — so that errors from earlier middleware/routes propagate down to it.

  20. How do you handle 404 (route not found) errors in Express?

    Add a catch-all middleware after all routes, e.g. app.use((req, res) => res.status(404).send('Not Found')); it runs when no earlier route matched the request.

  21. How can you set a custom status code on an error passed to next()?

    Attach a property to the error object, e.g. const err = new Error('Forbidden'); err.status = 403; next(err); then read err.status in the error handler to call res.status(err.status).

  22. What is the DEBUG environment variable used for in Express?

    It enables Express's internal debug logging via the debug module. Setting DEBUG=express:* (e.g. DEBUG=express:* node app.js) prints detailed logs of routing and middleware execution to help diagnose issues.

  23. What are effective debugging tips for an Express application?

    Use DEBUG=express:* for internal logs; add request-logging middleware like morgan; use console.log or the Node inspector (node --inspect) with breakpoints; check middleware order; and always include an error-handling middleware to surface stack traces.

  24. Why is a hanging (never-responding) request often a middleware bug, and how do you debug it?

    It usually means a middleware neither sent a response nor called next(), so the chain stalls. Debug by logging entry/exit of each middleware to find where control stops, and ensure every non-terminal middleware calls next().

What this deck covers

The Core Concepts of ExpressJS deck follows the ExpressJS Core Concepts of ExpressJS syllabus — 4 chapters and 16 topics — so questions land on material that is genuinely examinable rather than trivia around it. That works out to roughly 12.8 cards per chapter.

Answers are written to be recallable, not just readable — averaging about 194 characters, which is long enough to carry the reasoning and short enough to say out loud.

A deck like this earns its keep on the second and third pass. Read the syllabus first so you know the shape of the subject, then use the cards to find the specific facts that have not stuck.

Core Concepts of ExpressJS flashcards FAQ

How many Core Concepts of ExpressJS flashcards are in this ExpressJS deck?

51 cards. This page previews 24 of them, sampled evenly across the deck so you can judge the difficulty before installing anything.

Are these ExpressJS flashcards free?

Yes. The preview here is free to read with no signup, and the full 51-card deck is free inside the Examius app.

What do the Core Concepts of ExpressJS cards cover?

They follow the ExpressJS Core Concepts of ExpressJS syllabus — 4 chapters and 16 topics — so the questions track what is actually examinable.

How should I use these flashcards?

Read the syllabus first so you know the shape of the subject, then drill the deck. Examius schedules each card with spaced repetition, so cards you keep missing come back sooner and ones you know drift further apart.