Using Modules to Organize Code in Javascript


Modules allow you to split your code into separate files.

Source Code

// In module.js
export function sayHello(name) {
  console.log(`Hello, ${name}!`);
}

// In main.js
import { sayHello } from './module.js';
sayHello('John');
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments