3 ms·
`*` is the namespace object. `default` is a special named property on the namespace object. someModule.js: export default 'foo'; export const bar = 'b
by AprilArcus 4y ago
`*` is the namespace object. `default` is a special named property on the namespace object.
someModule.js:
export default 'foo';
export const bar = 'bar';
namespaceImport.js:
import * as SomeNamespace from './someModule.js';
console.assert(SomeNamespace.default === 'foo');
console.assert(SomeNamespace.bar === 'bar');
defaultImport.js:
import foo from './someModule.js';
console.assert(foo === 'foo');
namedImports.js:
import { default as foo, bar } from './someModule.js';
console.assert(foo === 'foo');
console.assert(bar === 'bar');
- HeavyFeather 4y agoNote that there's an error on the default export: - export default foo = 'foo'; + export default 'foo';
- AprilArcus 4y agothanks, fixed
- jenadine 4y agoA lot of 'x1' should be 'x2' in the examples