JavaScript 방식으로 export
하는 방법
{
"name": "5_module",
"version": "1.0.0",
"description": "",
"main": "app.js",
"type": "module",
"scripts": {
"test": "echo \\"Error: no test specified\\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
// count.js
let count = 0;
export function increase() {
count++;
}
export function getCount() {
return count;
}
JavaScript 방식으로 import
하는 방법
// app.js
import { increase, getCount } from './count.js';
increase();
increase();
increase();
console.log(getCount());