ForgeFrontend — Prepare, Practice, Crack
Secure checkout
Lifetime access
Instant Drive delivery
Free updates forever

Prepare · Practice · Crack

Named vs default exports in ES modules?

Quick answer

Named exports export multiple values by name; a default export is the module's single primary value.

In detail

Use named exports for utilities (`import { a, b }`) — names must match. Use a default export for the main thing a module provides (`import anything`) — the importer chooses the name. Modules run once, in strict mode, and are loaded asynchronously.

// utils.js
export const PI = 3.14;
export default function area(r) { return PI * r * r; }
// app.js
import area, { PI } from "./utils.js";

Why interviewers ask this: Everyday module fluency.

This is 1 of 118+ questions in the JavaScript Interview Kit

Get every question with detailed answers, follow-ups and real code — plus coding challenges and a last-minute revision sheet. One-time payment, instant access.

⚡ Get the JavaScript Interview Kit → ₹299

Full kit

JavaScript Interview Kit · ₹299

Get it →