SyntaxStudy
Sign Up
JavaScript Importing Named Exports
JavaScript Intermediate 4 min read

Importing Named Exports

Importing Named Exports

Import named exports using curly braces with the exact exported name. You can import multiple names in one statement.

Example
// Import specific names
import { add, multiply } from "./math.js";

console.log(add(2, 3));       // 5
console.log(multiply(4, 5));  // 20

// Import with renaming
import { add as sum, PI as pi } from "./math.js";

console.log(sum(1, 2)); // 3
console.log(pi);        // 3.14159
Pro Tip

Import only what you need — tree-shaking tools remove unused exports from production bundles.