일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- windowwidth
- ROUTER 버전6
- classList add
- classList
- 접근성
- chart responsive
- react-router
- classList remove
- nuxt layout
- 냥빨이다가온다
- 배열중복제거
- 2020
- 내배위의고양이
- chart.js
- classList toggle
- 포트폴리오
- 안짤렸다
- 대표님물리기없기
- vue3 setup
- 리엑트할수있는퍼블리셔라규
- react
- nuxt.js
- 간식금지다!
- 방심은금물
- 퍼블리싱
- react-router-dom
- 클래스 토글
- 커스텀훅
- 언젠간가겠지
- new set()
- Today
- Total
목록code/Javascript (18)
틈
es2015 에서 추가된 생성자입니다. 간단!const arr = [1,2,3,1,1,2];const set = new Set(arr);console.log(set);// expected output : {1,2,3};const newArr = Array.from(set);console.log(newArr)// expected output : [1,2,3];
es2015에서 추가된 생성자 입니다. Map 개체는 키-값으로 순서를 기억합니다. 1. 생성방법(키-값 추가)const map1 = new Map();map1.set("a", 1);map1.set("b", 2);map1.set("c", 3); 2. 불러오는 방법map1.set("a", 97);console.log(map1.get("a"));// Expected output: 97console.log(map1.size);// Expected output: 3map1.delete("b");console.log(map1.size);// Expected output: 2console.log(map1.has("a"));// Expected output: truem.clear();console.log(m.size..
fragment는 dom을 담는 그릇이다.위와 같은 html이 있을 때, ul.list 안쪽에 li를 추가하려면const docFragment = document.createDocumentFragment();const arr = ['a','b','c'];for(let i = 0;i 이렇게 추가하면 a b c위와 같은 dom을 얻을 수 있다.

js에서 class를 줬다 뺐다 할 때 사용하는 문법. classList 1. 클래스 넣어주기 선택자.classList.add('class') 2. 클래스 빼주기 선택자.classList.remove('class') 3. toggle 선택자.classList.toggle('class') 선택자.classList.toggle('class', 조건값) 4. 클래스를 가지고 있는지 확인하기 선택자.classList.contains('class') - true, false 반환 classList : className className은 class를 나열해주는 역할 classList는 객체로 내보내준다.
new Set() array 에서 중복 제거할 때 사용 사용방법 const arr = [1,2,3,4,5,6,1,2]; const set = new Set(arr); console.log(set); // {1,2,3,4,5,6} console.log([...set]) // [1,2,3,4,5,6] 중복을 해결하고 싶은 arr 변수를 인자를 넣고 출력하면 위와 같이 set 형태가 출력되는데, 이를 전개연산자를 이용해 다시 출력하면, 중복이 제거된 객체를 얻을 수 있다. new Set(객체).add(1) : 객체에 1 추가 new Set(객체).delete(1) : 객체에 1 삭제 new Set(객체).has(1) : 객체에 1이 있는지 없는지 체크 new Set(객체).size() : length 와 동일
가끔 다른 분들이 작업하던 js에서 try catch 구문을 확인하곤 했는데, 사용되는 의미를 몰라 '개발자가 사용하는 구문인가 보다.' 라고 생각하곤 했습니다. js에서는 구문 오류가 나면 바로 오류를 뱉어내고 프로그램이 정지하는데, 대형 프로그램을 작성할 때, 프로그램이 정지하지 않고, 오류를 받는 방법이라고 해서 앞으로 많이 사용할 것 같습니다. try { console.log("프로그램 실행") } catch(e) { console.log("에러 발생") console.log(e.name); console.log(e.message); } finally {} try catch 구문에서 finally 구문은 거의 본적이 없는데 이를 사용하는 이유는 강제실행이 필요할 경우입니다. try 구문 내 ret..