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);

Preorder my new course on Web Components! Want to learn how to build Web Components from scratch, master best practices, and more? Preorder today and get $100 off of the launch price.


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