export

· NODE.JS
여러 가지 export 방법 Node.js에는 여러 방법으로 모듈 내보내기를 할 수 있다. // 가장 자주 사용하는 방법은 // module.exports = {} // 상수도 export 가능 module.exports.A = 1; // 이런 식으로도 export 가능 module.exports.encrypt = function encrypt(data) { return "encrypted data"; } // module 생략해도 가능 exports.someFucntion = function someFucntion() { console.log("노드js"); } // module.exports = {}, 마지막에 export를 모아두는 방법 function send(url, data) { const e..
· TYPESCRIPT
타입 내보내기 typescript 파일에서 어떤 특정한 타입을 export 키워드를 이용해 내보낼 수 있고, import를 이용해 가져다 쓸 수도 있다. Type export export interface Uuser { firstName: string lastName: string age:number isValid: boolean } export function getFullName(user: Uuser) { return `${user.firstName} ${user.lastName}` } Type import import { Uuser, getFullName } from './exportuser' const gohome: Uuser = { firstName: 'crust', lastName: 'chee..
· JAVASCRIPT
모듈은 필요한 걸 가져다 쓰기만 하면 되는 거 같기도 하고, 깊게 파면 내 생각보다 복잡한 거 같아서 미뤄왔다. 그래도 아무 생각 없이 중괄호 쓰고 그냥 가져오고 하는 것보다 알고 쓰는 게 좋을 거 같아서 정리했다. // 모듈(Module)이란 특정 데이터들의 집합(파일) // 모듈 가져오기(import), 모듈 내보내기(export) // 가져오기(import) 선언은 모듈의 최상위 수준에서만 사용 가능 export const hello = function () { console.log('Hello world!'); } // import { hello } from './module.js'; // 기본 내보내기, 이름이 지정되어 있지 않으므로 임의의 이름을 지어 가져올 수 있음 export default..