일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
- python algorithm
- typeScript
- 파이썬
- 알고리즘
- node.js
- 자바스크립트
- OS
- useState
- inversion of control
- 비동기
- Python
- REACT
- 자료구조
- JavaScript
- Operating System
- Zerobase
- Computer Science
- algorithm
- java
- 프로그래머스
- execution context
- codestates
- context switching
- 개발공부
- react 기초
- 파이썬 알고리즘 인터뷰
- 운영체제
- 코드스테이츠
- 자바
- 컴퓨터공학
- Today
- Total
목록Programming Languages/JavaScript & Node.js (30)
Back to the Basics
NODEJS비동기의_이해와_비동기 처리에 대하여 참고 사이트 참고 사이트2 이번 주에 면접을 봤는데, 나왔던 질문 중 비동가와 관련된 질문이 있었다. 서버에서 Promise가 무엇인지 알고 있는지 Async Await은 어떻게 다른지 Server에서 비동기가 언제 쓰이는지 알고 있는지 첫 번째 질문에서는 CallBack지옥을 피하기 위해 나왔고 비동기 처리를 해주는 것이라고 말하였고 두 번째 질문은 Promise 지옥을 피하기 위해 생겨났으며 async로 비동기 처리가 있음을 알리는 키워드로 사용되고 await은 지금 이 함수가 비동기 함수라는 것을 명기해주는 키워드라고 이야기하였다. 세 번째 질문의 답으로는 상대적으로 오래 걸릴 수 있는 DB 쿼리를 할 때 주로 쓴다라고 이야기를 하였다. 틀린 대답은 ..
JAVASCRIPT-실행컨텍스트 모던 자바스크립트 Deep Dive를 읽고 정리한 포스팅 23장-실행컨텍스트-Execution-Context 언어를 공부한다는 것은 단지 언어의 문법만 공부하는 것이 아니라 자바스크립트가 실행되는 환경에 대한 이해, 이 환경에서 자바스크립트가 어떻게 코드를 관리하는지, 그리고 툭 하면 언급되었던 호이스팅에 한 이해.. 그리고 싱글스레드 기반인 자바스크립트의 Event loope등 그 언어의 동작 원리를 알아야 삽질을 덜 하고 더 효율적인 코드를 작성할 수 있다. 그리고 실행 컨텍스트는 자바스크립트의 동작 원리를 담고있는 아주 핵심적인 개념이다. 이 책에는 실행컨텍스트에 대해 정말 자세히 설명이 되어있어서 그동안 두리뭉실하게 알고 있었던 부분을 해결할 수 있었다. ECMAS..
About_export_exports_module.exports 이전 포스팅에서 require()에 대해 알아보았다. 이번엔 require와 함께 붙어 다니는 exports에 대해 알아보자 1. export는 왜 하는 것일까? exports를 하는 경우는 1. Node의 내부 모듈을 사용할 때 2. 작성한 js파일을 다른 js파일에서 불러와야 할 때 사용한다. 두 경우의 공통점은 “모듈"이라는 사실이다. 모듈이란, 우리가 만드는 applicaion을 구성하는 개별적인 요소로, 재사용이 가능하도록 만들어졌다. NodeJS에서 모듈을 따로 export 해주지 않는다면 모듈 내부의 함수,변수 등의 자원은 사용하지 못한다. 이는 모듈 자체로 스코프를 갖고 있기 때문이다. 이를 “모듈 스코프"라고 한다. 따라서,..
About require() node.js에서는 module을 불러올 때 require를 사용한다. 그리고 로컬에 작성한 파일을 다른 파일에서 사용하기 위헤 꼭 export를 해야한다. 지금까지 사용을 하면서 단순히 exports를 하면 require를 할 수 있다고만 알고 있었다. 글이 길어질듯 하니 먼저 require를 하면 내부적으로 어떤 작업이 이루어지는이 알아보자. 1. require()는 module.exports를 return 한다. 노드 사이트 참고 위의 문서에 따르면, require는 기본적으로 Javascript file을 읽고, 그 파일을 실행시킨 후 exports 객체를 return 한다. 공식 사이트에 있는 예제를 예로 들면 // example module var invisible..
degut module Node.js Debug Module debug 모듈은 console.log()를 대신하는 로깅 모듈로 node.js에서와 web browser에서 동작한다. node에서 가장 많이 사용하는 모듈이라고 한다. 로그를 구조적으로 기록할 수 있다는 점에서 console.log보다 뛰어나다. 이 모듈은 로그롤 구조화하여 기록할 수 있으며 특정 로그만을 볼 수 있도록 지정할 수 있다는 장점이 있다. HOW TO USE debug를 선언한다 const debug=require('debug') debug id를 정의한다. // debug를 선언할 때 하는 방법 const server=require('debug')("shortly:server"); const request=require('de..
Anatomy of an HTTP Transaction 이 글은 Anatomy of an HTTP Transaction을 읽고 정리한 글입니다. 개인적인 정리이니 의역 다분함을 명심해 주세요. 이 내용을 알기 위해서는 EventEmitter와 Streams에 대해 어느 정도 친숙해야 한다고 한다. (그것을 가정하고 작성된 문서이다) Create the Server node web server는 createServer를 사용하여 web server object를 생성하면서 시작하다. server object는 EventEmitter이다. http.createServer([options][, requestListener]) Syntax cosnt http=require('http') http.createSe..
Events 이 글은 Node.js Ver 17.0.1 documentation을 읽고 정리한 글입니다. 개인적인 정리이니 의역 다분함을 명심해 주세요. Node.js의 대부분 API는 event를 내보내는 "event 기반의 아키텍처"를 사용해서 만들어졌다. emitter라는 특정한 종류의 객체가 내보내는 event는 listeners라고 불리는 함수를 호출한다. 예를 들어, net.Server Object는 peer가 연결할 때마다 event를 내보내고, fs.ReadStream은 file이 열릴 때마다 event를 내보낸다. 그리고 stream은 data가 읽을 수 있을 때마다 event를 내보낸다. 이와 같이 events를 내보내는 모든 객체는 EventEmitter Class의 Instance이..
Underbar Night mare 이번 포스팅에서는 미루고 미뤄왔던 Nightmare 포스팅을 진행하겠다. _. memoize : momoise() method는 Lodash 라이브러리의 method이다. 이미 계산된 값을 일시적으로 기억했다가 다시 호출할 때 다시 계산하지 않고 기억한 값을 출력한다. 이미 해결한 문제는 다시 풀지 않는 기법이다. 완전하게 Lodash 라이브러리의 memoization 구현을 한 것은 아니겠으나, 추후 Memoization에 대해 공부할 일이 생긴다면 한번 더 구현을 해보기로 하자. Parametar func : callback 함수로 memoization을 적용하고자 하는 함수. _.memoize = function (func) { // memo를 하기위한 배열을 선..