Export/import before ES6:
javascriptfunction sum(a, b){ return a + b; } function sub(a, b){ return a - b; } module.exports = { sum, sub };
javascriptconst ({ sum, sub }) = require('./Math');
Export/import after ES6:
javascriptexport const sum = (a, b) => a + b; export const sub = (a, b) => a - b;
javascriptimport { sum, sub } from './Math';
Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.