step 2-1 demo notes

This commit is contained in:
Ken
2019-02-21 13:40:14 -08:00
parent 102c14648a
commit 91f7b2c046
3 changed files with 15 additions and 3 deletions

View File

@@ -1,4 +1,10 @@
import { namedConst, namedFn, namedObj, namedConstBracket, namedConst as c } from './named';
// 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
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
import * as named from './named';
// Print out the exports
@@ -14,6 +20,9 @@ console.log(named.namedFn());
console.log(named.namedObj);
console.log(named.namedConstBracket);
// Default import can be named anything we want as the consumer
import DefaultClass from './default';
import Foo from './default';
console.log(new DefaultClass().hello);
console.log(new Foo().hello);

View File

@@ -9,4 +9,5 @@ export const namedObj = {
};
const namedConstBracket = 10;
export { namedConstBracket };