1. Home
  2. Explore
  3. Computer Science
  4. Async JavaScript Pitfalls

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Async JavaScript Pitfalls

  • 21Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Async Landscape
  • spaceFlip card
  • KI knew it
  • DI didn't know it
  • ←Previous card
  • →Next card

What are the four quadrants of the asynchronous programming landscape?

Tap to flipClick to flipspace

Synchronous single value (function/assignment), synchronous multiple values (iterable/collection), asynchronous single value (callback/promise), asynchronous multiple values (observable).

Or swipe the card

21 cards

  1. What are the four quadrants of the asynchronous programming landscape?

    Synchronous single value (function/assignment), synchronous multiple values (iterable/collection), asynchronous single value (callback/promise), asynchronous multiple values (observable).

  2. What is callback hell?

    Nested callback functions that make code hard to read and maintain, often resulting in a 'cow's head' shape where logic is lost.

  3. How does the movie player example illustrate callback hell?

    Initialization, authorization, and playing are nested callbacks: player.init(function() { auth(function(ticket) { play(ticket); }); });

  4. What is a promise?

    A first-class object representing an eventual value; it can be passed around and has a standard .then() for success and .catch() for error handling.

  5. What are the two main limitations of promises mentioned in the talk?

    1. Cancellation is not part of the ES6 promise contract. 2. Promises handle only a single value, not streams of events.
  6. What is an observable?

    An asynchronous, first-class object representing a stream of multiple values over time; supports operations like map, filter, and forEach.

  7. What does 'your mouse is also a database' mean?

    Mouse events (coordinates) can be treated as a queryable stream, just like an array (iterable sequence).

  8. How does the Rx solution for mouse drag work?

    Combine mousedown and mousemove using flatMap, calculate offset, and takeUntil mouseup to stop the drag.

  9. What is reactive programming according to the talk?

    Reacting to events, load (scaling), failure (fallback), and especially reacting to users (responsiveness).

  10. How does an autocomplete scenario use throttling/debounce?

    Throttle (debounce) the input stream to avoid overloading the server: wait for a pause (e.g., 500ms) before firing the request.

  11. What is the difference between FRP (Functional Reactive Programming) and observables?

    FRP uses continuous time and behaviors (values continuous over time) and events (only at firing moments). Observables are discrete streams of events, not continuous.

  12. What does a generator do with yield?

    yield suspends execution of the generator function and resumes when the next value is requested (via .next()).

  13. What is the async/await syntax?

    async defines an asynchronous function; await pauses execution until a promise resolves, making async code appear synchronous.

  14. What was problematic about Node.js Streams 1?

    Pause didn't work, data didn't start immediately, couldn't consume specific byte counts, and pause/resume was impossible.

  15. What improvements did Node.js Streams 2 bring?

    Supported object mode, instant flowing, and introduced readable/writable classes, duplex, and pass-through streams.

  16. What is the goal of WHATWG Streams?

    Standardize lower-level APIs for stream handling in browsers, with concepts like 'cast' (single reader/writer).

  17. How does Dart unify asynchronous programming?

    It uses futures (single value) and streams (multiple values) with a unified API for I/O and events.

  18. What is back pressure in the context of observables?

    Mechanisms to control data flow when a consumer cannot keep up: lossy (sampling), lossless (pauseable buffer), or controlled (request N items).

  19. What is a reactive stream?

    An effort to standardize back pressure across observable implementations, allowing subscribers to request a specific number of items.

  20. What is an async generator?

    A proposed ES feature combining generators and async: async function* that yields promises and can be consumed with for await...of.

  21. How does for/await...of work with async generators?

    for await (const event of asyncGenerator) loops over yielded async values, waiting for each promise to resolve.

Card 1 of 21
Card 1 of 21

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent