네트워크/CS Study
-
[CS Study] 스코프란 & 호이스팅이란 무엇일까???네트워크/CS Study 2023. 6. 19. 17:19
스코프란 무엇인가? 변수의 유효범위를 말하는 것이고 이 유효범위의 이해를 위해서 간단한 예제 코드를 보면서 알아보자. let greeting = 'Hello'; function greetSomeone(){ let firstName = 'KJ'; return greeting + ' ' + firstName; } console.log(greetSomeone()); // Hello KJ하위스코프는 상위스코프에 접근이 가능 // console.log(firstName); // 접근 불가능 상위스코프는 하위스코프에 접근 불가능 전역스코프 && 지역스코프 전역스코프는 가장 바깥에 있는 스코프를 가르키고 지역스코프는 전역스코프 외 스코프를 가리키는 말이다. 스코프체인 이러한 전역, 지역 스코프에 대한 개념이 함수와 ..
-
[CS Study] fetch / axios && API란 무엇일까?네트워크/CS Study 2023. 6. 18. 13:16
API 란??? 하나의 프로그램에서 다른 프로그램으로 데이터를 주고 받기 위한 방식으로 상당히 추상적인 개념이기 때문에 잘 짚고 가야하는 부분이다. 식당 메뉴판을 상상하면서 API를 이해해 보자 (김치찌개를 원하면 아줌마에게 김치찌개 달라고 해야지 김치찌개인데 참치 넣고 햄넣고 사리까지 듬뿍 넣어서 주세요 하면 안된다;; ===) 작성방식 어떤 요청방식이 들어가야 한다 ( get, post 와 같은 것이 요청방식임) 어떤 자료를 요청할 지 적어야 한다 (대표적으로 URL) 추가정보는 넣든말든 (유저정보 기타등등 URL에서 ? 뒤에 들어가는 내용임) 웹에서만 작동하는 개념이 아니기 때문에 윈도우 데이터 관리 등등 걍 데이터를 주고받는 곳에서는 다 쓰이는 용어이기 떄문에 잘 안고가즈아... Fetch / A..
-
async /await 에 대하여네트워크/CS Study 2023. 6. 14. 23:14
1. 사용하는 이유 비동기 처리를 하는 가장 기본적인 call back 함수를 이용한 처리와 promise 객체를 이용한 처리가 단점이 많다. promise 객체를 더욱 더 가시성 좋게 사용하기 위해 사용합니다 promise와 callback의 단점 1. 보기에 너무 나쁘다 call back 지옥 보면 토나오는 모양새이고 promise 또한 then으로 병렬적으로 쓰여진 것도 에러가 발생했을 때 찾기 좀 힘들고 들여쓰기가 많이 들어간다면 정신건강에도 나쁘다. 2. catch() 메서드를 사용해서 에러에 대해서 예외처리를 할 때 동기코드와 비동기코드가 섞여 있으면 누락이 있거나 난해해지는 경우가 있다. 그래서 async/await은 promise를 이용한 비동기처리의 불편함을 개선하기 위해서 ES7에서 새..