| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 |
- 안드로이드 스튜디오
- Global
- 파라메트릭 서치
- 객체지향
- Async
- __dirname
- 이진탐색
- await
- 8기
- JPA
- 프롬프트엔지니어링
- 우테코 프리코스
- 프리코스
- nodejs
- exports
- Console
- 객체지향의 사실과 오해
- oAuth2
- HttpCookieOAuth2AuthorizationRequestRepository
- 백준
- CommonJS
- __filename
- MAX_VALUE
- 다이내믹 임포트
- 순환참조
- 우테코
- import.meta.url
- 이분탐색
- 노드 내장 객체
- 프롬프트
- Today
- Total
목록Back-End/nodejs (3)
코딩하는 감쟈
global 브라우저의 window와 같은 전역 객체이다. 따라서 모든 파일에서 접근할 수 있다. globalA.js module.exports = () => global.message; globalB.js const A = require('./globalA'); global.message = '안녕하세요'; console.log(A()); globalA 모듈의 함수는 global, message 값을 반환한다. globalB에서는 global 객체에 속성명이 message인 값을 대입하고 globalA 모듈의 함수를 호출한다. console console.js const string = 'abc'; const number = 1; const boolean = true; const obj = { outs..
var.mjs export const odd = '홀수입니다'; export const even = '짝수입니다'; func.mjs import { odd, even } from './var.mjs'; function checkOddOrEven(num) { if (num % 2){ return odd; } return even; } export default checkOddOrEven; index.mjs import { odd, even } from './var.mjs'; import checkNumber from './func.mjs'; function checkStringOddOrEven(str) { if(str.length%2) { return odd; } return even; } console...
var.js const odd = '홀수입니다'; const even = '짝수입니다'; module.exports = { odd, even, }; module.exports에 변수들을 담은 객체를 대입했다. 해당 파일은 모듈로서 기능한다. module.exports는 한 파일에 한개씩만 가능하다. func.js const { odd, even } = require('./var'); function checkOddOrEven(number) { if(number % 2) { return odd; } else { return even; } } module.exports = checkOddOrEven; require 함수로 var.js에 있던 값들을 불러오고 있다. const{ odd, even }은 구조분해..