🔹 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
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter