Skip to main content Accessibility Feedback

ES Modules

import all

Instead of naming every function you want to import, you can alternatively import everything, and assign all of the imported items to a variable.

Instead of using object destructuring, import *, then, assign it to a variable using the as opertor. In our case, let’s use an underscore (_), common with helper libraries.

import * as _ from './helpers.js';

// Get the total
let total = _.add(num1, num2);

Join the Lean Web Club! Coaching. Courses. Coding resources. Get the skills, confidence, and support you need to learn front-end web development and achieve long-term success.


Find this useful? You can support my work by purchasing an annual membership.