분류 전체보기
-
[프로그래머스 알고리즘] 2중반복문알고리즘 2023. 6. 22. 09:57
K번째 수 function solution(array, commands) { let answer = [] for(const i of commands) { let newArr = [] for (let j = i[0] - 1; j a-b)[i[2] - 1]) } return answer } 다른사람 답 function solution(array, commands) { return commands.map(command => { const [sPosition, ePosition, position] = command const newArray = array .filter((value,..
-
[리액트 다루는 기술] 리덕스 작동원리 && 기초프로그래밍/React 2023. 6. 21. 16:28
리덕스란?? 상태관리 라이브러리의 일종으로 상태업데이트 관련 로직을 다른 파일로 분리시켜서 효율적인 관리가 가능하며 contextAPI와 비슷하게 사용 될 수 있으나 실상 다른 여러기능도 많고 미들웨어 등등 보다 체계적인 관리가 가능해서 contextAPI보다 널리 쓰이고 있다. 허나 16v에서 contextAPI의 기능이 좋아지고 나서는 잘 모르겠음 바닐라 자바스크립트가 많이 쓰이는 이유가 이녀석떄문인것 같다. 불변성을 항상 유지해야한다. 용어정리 액션 상태에 변화가 필요하면 발생한다. 하나의 객체로 표현되며 type필드를 반드시 가지고 있어야하고(이게 이름임) 추가적인 업데이트 때 참고 할 사항을 넣을 수 있다. 그러니 이렇게 만들려면 함수가 있어야 하는데 이게 액션 생성함수이다 {type : "TO..
-
[항해99 WIL] ES5 VS ES6네트워크/CS Study 2023. 6. 21. 14:08
왜 알아야하는가? 모든 회사가 최신 문법을 항상 사용한다는 생각이라면 굳이 안해도 된다. 하지만 일말의 가능성도 있으니 레거시를 분석할 때 이해를 못하면 좀 쪽팔릴것이다 그래서 알아야한다. ES5는 2009년에 ES6 2015년에 출시된 것으로 뒤에 숫자는 각각의 버전을 의미하고 있다 뭐가 바뀌었냐? 1. ES5 strict mode (엄격 모드)의 도입 : 코드 자성의 실수나 잠재적인 오류를 방지하기 위한 규칙 도입 배열 메소드 추가: forEach, map, filter, reduce 메소드 JSON객체 bind 메소드 등 2. ES6 let과 const의 도입: 블럭 범위 변수 선언 지원 화살표 함수('=>') : 더 간결한 함수 표현식을 작성할 수 있게 되었다. 이 화살표 함수는 함수 컨텍스트 내..
-
[CS Study] Closure네트워크/CS Study 2023. 6. 21. 13:51
클로저란? 정의로써는 함수와 함수가 선언된 어휘적 환경의 조합이란다. ???? 그냥 전역스코프에 선언한 변수는 아무대서나 건드릴 수 있으니 아무나 못건드리고 나만 건드릴 수 있게 만들어주는 녀석이다. 클로져는 상태를 안전하게 활용하기 위해서 사용되어야 한다 === 의도치 않은 변경은 막아야지 써야하는 이유? 그래서 왜 아무나 건드리면 안되는데? 라고 물어보면 다음과 같은 상황을 볼 수있다. var x = 1; var y = 1; function sumOne() { return x++ } function ySum() { return y++, x++ } sumOne() console.log(x) // x = 2 sumOne() ySum() x++ console.log(x) // x = 5 나는 sumOne(..