Explain JavaScript code

Paste JavaScript, whether it is a callback, a promise chain or an async function, and Vibe explains what runs when.

profiles.js

Up to 1,500 characters (about 60 lines). Your code is sent to Unvibe and Anthropic to write the explanation. Don't paste keys or passwords. Common key formats are refused.

Vibe24 lines selected

Press Explain it for the sample, or paste your own code first.

What this JavaScript sample shows

promises
fetch returns a promise for each id, and Promise.allSettled waits until every one has either resolved or rejected. It never rejects itself, so one failed user doesn't lose the others.
event loop
The script prints before, then after, and only then the count. await pauses loadProfiles and hands control back, so the last console.log runs while the requests are still in flight.
closures
The arrow function inside ids.map closes over its own id, so each error message names the right user even though the requests can finish in any order.

Good to know

  • All the requests start at once, because map calls fetch for every id before anything is awaited. To send them one at a time, await each one inside a for...of loop.
  • fetch only rejects when the request itself fails, such as a network error. A 404 or a 500 still resolves, which is why the code checks res.ok and throws.
  • With Promise.all instead, the first failure would reject the whole call and the profiles that did load would be lost.
  • results keeps the same order as ids, which is why ids[i] finds the id of a failed request.

Watch out: A relative URL like /api/users/1 only works in a web page. In Node.js, fetch needs a full URL, so every request here would fail with Failed to parse URL and end up in failed.

Explain JavaScript code beside your editor

Unvibe is a free app for Mac and Windows. In the app there is no pasting: select code in any app and press Control+U (Ctrl+Alt+U on Windows).

Install on Mac

curl -fsSL https://unvibe.site/install.sh | bash

Paste into Terminal. Unvibe isn't notarized by Apple yet, so this is the smooth path.

No install warning? Use Unvibe in your browser

Opening the .dmg the first time
  1. Open the .dmg and drag Unvibe to Applications.
  2. Open it once; macOS says it can't verify it. Click Done.
    macOS dialog: Unvibe Not Opened, with Done and Move to Trash
    Real screen, macOS 15
  3. System Settings › Privacy & Security › Open Anyway. Confirm, then enter your Mac password. The button shows for about an hour after you try to open Unvibe.
    macOS Privacy & Security, Security section: Unvibe was blocked to protect your Mac, with the Open Anyway button
    Real screen, macOS 15

The Terminal line checks the download against the published SHA-256 and Unvibe's self-signed signature before it installs anything. More help with the first open