Professional Documents
Culture Documents
Import Export Modules
Import Export Modules
mobile.js
export class Nokia { export function show () { export const a = 10;
Properties
Methods }
}
mobile.js
class Nokia {
Properties
Methods
}
export {Nokia, show};
function show () {
}
export const a = 10;
Importing Module
import - The static import statement is used to import bindings which are
exported by another module. Imported modules are in strict mode whether you
declare them as such or not.
Importing Defaults
You can have only one default export per module. A default export can be
imported with any name.
mobile.js app.js
class Nokia { import Nokia from ‘./mobile.js’
Properties
Methods
}
export default Nokia;
Importing Named
You can have multiple named exports per module. Named exports are useful
to export several values. During the import, it is mandatory to use the same
name of the corresponding object.
mobile.js app.js
export class Nokia {
import {Nokia} from ‘./mobile.js’
Properties
Methods import {Nokia, show}from ‘./mobile.js’
}
function show () {
}
export {show};
Importing All
mobile.js app.js
class Nokia { import * as device from ‘./mobile.js’
Properties
Methods
} device.Nokia
export function show () { device.show
device.a
}
Export const a = 10;
export {Nokia};
Importing Default and Named
mobile.js app.js
class Nokia { import Nokia, {show} from ‘./mobile.js’
Properties
Methods
}
export function show () {
}
export default Nokia;