JavaScriptIntermediate#es6#modules

What is the difference between a module and a script? (import/export)

ES modules have their own scope, are always strict, load deferred and support static import/export analysis for tree shaking. Classic scripts share the global scope.

Example
// utils.js
export const add = (a,b) => a+b;
export default add;
// app.js
import add, { add as named } from './utils.js';

Related Questions

1
JavaScriptIntermediate#objects

What is the difference between Object.freeze and const?

Open
2
JavaScriptBeginner#numbers

What is NaN and how do you check for it?

Open
3
JavaScriptIntermediate#numbers

Why is 0.1 + 0.2 !== 0.3?

Open