parent
8c7292d813
commit
f297f0cf15
@ -0,0 +1,12 @@
|
|||||||
|
// index.js
|
||||||
|
// to import the doSomeMath from the math.js with or without extension
|
||||||
|
import doSomeMath from './math.js'
|
||||||
|
|
||||||
|
// to import the other modules
|
||||||
|
// since these modules were not exported as default we have to desctructure
|
||||||
|
import { addTwo, multiply, subtract } from './math.js'
|
||||||
|
|
||||||
|
import * as everything from './math.js' // to import everything remaining
|
||||||
|
console.log(addTwo(5, 5))
|
||||||
|
console.log(doSomeMath.addTwo(5, 5))
|
||||||
|
console.log(everything)
|
@ -0,0 +1,12 @@
|
|||||||
|
// math.js
|
||||||
|
export const addTwo = (a, b) => a + b
|
||||||
|
export const multiply = (a, b) => a * b
|
||||||
|
export const subtract = (a, b) => a - b
|
||||||
|
|
||||||
|
export default (function doSomeMath() {
|
||||||
|
return {
|
||||||
|
addTwo,
|
||||||
|
multiply,
|
||||||
|
subtract,
|
||||||
|
}
|
||||||
|
})()
|
Loading…
Reference in new issue