front-end(11)
-
React (1) - redux-saga
redux-thunk 대신 redux-saga 를 사용하는 이유 thunk 는 dispatch 를 여러번 불러오는 기능만 가지고 있다. npm i redux-saga npm i next-redux-saga redux-saga 액션을 모니터링하고 있다가, 특정 액션이 발생하면 이에 따라 특정 작업을 하는 방식으로 사용합니다. 여기서 특정 작업이란, 특장 자바스크립트를 실행하는 것 일수도 있고, 다른 액션을 디스패치 하는 것 일수도 있고, 현재 상태를 불러오는 것 일수도 있습니다. redux-saga는 redux-thunk로 못하는 다양한 작업들을 처리 할 수 있습니다. 예를 들자면.. 비동기 작업을 할 때 기존 요청을 취소 처리 할 수 있습니다. 특정 액션이 발생했을 때 이에 따라 다른 액션이 디스패치되게..
2022.04.03 -
JavaScript (4) - getElementById vs querySelecter
getElementById let element = document.getElementById(id); // id passwd 인 element 를 가지고 올 때 let passwd = document.getElementById("passwd"); querySelecter let element = document.querySelecter(selectors); // id passwd 인 element 를 가지고 올 때 let passwd = document.querySelecter("#passwd");
2022.04.03 -
JavaScript (3) - Window Size, Window.scrollTo, Window.scrollBy, Window Load 설명
Global Object ex) innerWidth ← Window 안의 innerWidth 를 가져온다. DOM - Document Object Model BOM - Browsers Object Model JavaScript Window Size window.screen 모니터 사이즈 - 브라우저 사이즈가 변경되어도 사이즈를 유지한다. window.outer 브라우저에 있는 url 상단,탭까지의 사이즈 window.inner 웹페이지(스크롤바 포함) documentElement.clientWidth 웹페이지(스크롤바 제외) page x,y (문서의 시작점) client x,y (브라우저 시작점) Window Coordinates scroll_to.addEventListener('click', event..
2022.04.03 -
JavaScript (2) - find() , filter() 함수 설명
find() 함수가 특정 조건에 부합하는 배열의 첫번째 값만을 리턴한다고 한다면, filter() 함수는 특정 조건에 부합하는 배열의 모든 값을 배열 형태로 리턴합니다. find() const arr = [ {name: 'apple', price : 1000}, {name: 'banana', price : 2000}, {name: 'apple', price: 3000} ]; arr.find((item)=>item.name === 'apple'); // {name: "apple", price: 3000} filter() const arr = [ {name: 'apple', price : 1000}, {name: 'banana', price : 2000}, {name: 'apple', price: 3000}..
2022.04.03 -
JavaScript (1) - 반목문(for, while, do..while )과 반복문 제어(break, continue)
1~10 까지의 수를 console.log() 함수를 이용하여 로그를 출력하려면 어떻게 코드를 작성 해야할까? console.log('1') console.log('2') console.log('3') console.log('4') . . . console.log('10') 위 코드처럼 작성할 수 있다. 그렇다면 1~100은? 1~1000000은 어떻게 작성해야할까? 사실상 위처럼 작성한다는 것은 말이 안됩니다. (할 수는 있겠지만.. 매우 비효율적이다.) 이를 위해 '반복문'을 사용할 수 밖에 없습니다. 실제 웹페이지에서는 반복문을 이용하여 메뉴를 보여주기도 하고 수백, 수천개의 게시글을 보여줄 때도 사용합니다. 반복문은 for과 while 이 대표적입니다. for 문 for(let i=0; i
2021.01.06