mirror of
https://github.com/microsoft/frontend-bootcamp.git
synced 2026-01-26 14:56:42 +08:00
Step 2-01 updates
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
// These are named imports from a file relative to this file
|
||||
import { namedConst, namedFn, namedObj, namedConstBracket } from './named';
|
||||
|
||||
// We can even apply an alias to the named constant
|
||||
// We can even give an alias to the named constant
|
||||
import { namedConst as c } from './named';
|
||||
|
||||
// These are the same instances of the named imports, but gets imported all at the same time under a single object
|
||||
// These are the *same instances* of the named imports, but they all get imported inside a single object
|
||||
import * as named from './named';
|
||||
|
||||
// Print out the exports
|
||||
@@ -14,12 +14,15 @@ console.log(namedFn());
|
||||
console.log(namedObj);
|
||||
console.log(namedConstBracket);
|
||||
|
||||
// Print out exports through module level import
|
||||
// Print out exports from module level import
|
||||
console.log(named.namedConst);
|
||||
console.log(named.namedFn());
|
||||
console.log(named.namedObj);
|
||||
console.log(named.namedConstBracket);
|
||||
|
||||
// The named and module-level imports reference the same object instances
|
||||
console.log(namedObj === named.namedObj); // true
|
||||
|
||||
// Default import can be named anything we want as the consumer
|
||||
import DefaultClass from './default';
|
||||
import Foo from './default';
|
||||
|
||||
Reference in New Issue
Block a user