1. 순수하게 input 만을 이용한 version. without any modules ModalTemp.js -> onChange 를 사용해서 상단으로 넘겨줘서 onSave로 넘긴 데이터 사용. 테스트 onSave(e)} /> 테스트2 onSave(e)} /> index.js -> 자식컴포넌트에서 받아온 data를 내가 저장할때 필요한 data 틀을 useState를 이용해서 만들어서 넣어준다 const [regist, setRegist] = React.useState({ test: '', test2: '' }); const registerHspt = (data) => { setRegist({ ...regist, [e.target.name]: e.target.value, }); . . 2. Modal..
const alphabets = [1,1,1,2,3,3,1,4,5]; const counts = alphabets.reduce((acc, current) => { if(acc[current]){ acc[current] += 1; } else { acc[current] = 1; } return acc; }, {}); console.log(counts); //{ '1': 4, '2': 1, '3': 2, '4': 1, '5': 1 }
child to parent window.opener(): 새 창을 만든 window를 reference window.postMessage(): window간의 cross-origin 통신을 가능하게 함. 메시지를 받을 때는, 윈도우의 ‘message’ 이벤트에 대한 핸들러를 등록하면 된다. window.opener.postMessage({ event: "DIALOG_OPEN" }, _url); window.addEventListener("message", (event) => { switch ((event.data || {}).event) { case "READING_ON": { this.readingOn(); break; } case "READING_OFF" : { this.readingOff(even..
window in Javascript - 어디서든 접근이 가능한 전역객체 - browser window를 의미하고, browser window를 control 할 수있는 다양한 method 제공 - 내가 작성하는 코드들이 이 window object의 property가 된다. 그래서 특별한 경우를 제외하고는 window는 생략이 가능하다. 단, const와 let은 scope가 object내에 속하기에 global object property로는 사용할 수 없다. - window.close() window.open() window.innerHeight window.innerWidth 등을 사용해서 window창 제어가능. // 1. 단축키를 사용 handle close function 호출 functio..
original code. setPeople function 은 multiple rows의 선택과는 관계없이 선택된 row가 single row인지만 확인한다. 1. 리덕스에서 받아온 selectedRows의 element 들을 굳이 각자 따로 받아와서 variable을 만들 필요가 없다. 2. array를 map 으로 loop 해서 받아온 것을 다시 assign하는 과정에서 다시 array 로 assign 하는 과정을 불필요하게 거침. function setPeople(result: any) { setDropdownList(result.map((people:any) => ({ label : `${people.name}(${people.email})`, value : people.id }))); cons..
map vs forEach map은 새로운 array를 리턴하고 forEach는 original array를 수정하여 리턴한다. -> 즉 기존 array를 남기는 map()을 사용하는 것이 함수형프로그래밍에 더 적합하다. forEach자체는 original array를 return하지만 callback function이 변화를 일으킨다. Example code. let arr = [1,2,3]; const arrMap = arr.map(x => x*2); console.log("arr", arr) //arr [ 1, 2, 3 ] console.log("arrMap", arrMap); //arrMap [ 2, 4, 6 ] arr.forEach((x, index) => arr[index] = x * 3); ..
- Total
- Today
- Yesterday
- rest parameter
- Collection Framework
- hackerrank javascript
- math.max
- spring boot application
- equals()
- ... in Javascript
- 알고리즘
- HackerRank Algorithm
- C++
- Javascript Algorithm
- 프로그래머스 알고리즘
- hackerrank javascript solution
- substring()
- Object type casting
- hackerrank solution
- easy algorithm
- code refactoring
- java
- hackerrank
- repeat()
- 프로그래머스 알고리즘문제
- easy javascript algorithm
- string class in java
- javascript
- compareTo()
- math.abs
- algorithm
- 프로그래머스
- HashMap
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |