Organizing Code with Modules in Javascript


Use modules to separate code into reusable pieces.

Source Code

// In file math.js
export const add = (a, b) => a + b;

// In another file
import { add } from './math.js';
console.log(add(2, 3)); // 5
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments