February 2019
Beginner
694 pages
18h 4m
English
When importing a module, we can rename the exported module as follows:
import {Module1 as m1} from './lib/Module1';
let m1mod1 = new m1();
mod1.print();
Here, we have imported the same module from './lib/Module1', but have used the as keyword when specifying the module name, that is, {Module1 as m1}. This means that we can now refer to the class named Module1 (as according to our export definition) as simply m1. The last two lines of this code sample show how we can now create a class (of type Module1) by using the new m1 name. The output of this code sample is exactly the same as the previous code:
print() called with Module1.print()
We can also have multiple names for an exported module, but these names need to be specified ...
Read now
Unlock full access