Working with Modules
Tue Apr 22 2025 19:53:14 GMT+0000 (Coordinated Universal Time)
Saved by
@signup
🔹 a. Exporting from a module
📁 File: mathUtils.js
// mathUtils.js
export const add = (a, b) => a + b;
export const subtract = (a, b) => a - b;
🔹 b. Importing in another file
📁 File: main.js
// main.js
import { add, subtract } from './mathUtils.js';
console.log(add(5, 3)); // 8
console.log(subtract(5, 3)); // 2
content_copyCOPY
Comments