1

In JavaScript, a developer can import multiple submodules from a module by using any of these syntax

import { submod1, submod2} from "module";

// Using the submodules
submod1();
submod2();

or

import * as module from "module";

// Using the submodules
module.submod1();
module.submod2();

Using the first method seems very involving especially when you need to import a lot of submodules; and yet that is what I see in most tutorials and documentations.

Is there any performance of technical advantage in using the first method over the second?

I'm asking this concerning modules which export in a way to allow both methods.

elSama
  • 87
  • 1
  • 9
  • 1
    They both look work just fine. If the other module only has a couple of named exports, you might prefer the first method so that you have standalone variable names. It's up to you. – CertainPerformance Jul 26 '19 at 22:38

0 Answers0