ES6 introduced native modules to JavaScript to support modular coding.
modules
// utils.js export function add(a, b) { return a + b; } // main.js import { add } from './utils.js'; console.log(add(2, 3));
Use export to expose functionality and import to bring it into other files.
export
import