모듈은 독립적인 파일 스코프를 갖기 때문에 모듈 안에 선언한 모든 것들은 해당 모듈 내부에서만 참조 가능
모듈 내에 선언한 항목을 외부에 공개하여 다른곳에서도 사용하고 싶다면 export 해야함
변수, 함수 클래스 모두 export할 수 있음
변수 공개
export const a = 1;
함수 공개
export function hello(a){
retrun 'hello';
}
클래스 공개
export class Person{
constructor(name){
this.name = name;
}
}
export 대상을 모아 한번에 export 처리
const a = 1;
function hello(a){
retrun 'hello';
}
class Person{
constructor(name){
this.name = name;
}
}
//한번에 공개
export{a, hello, Person};