티스토리 뷰
목차
spread
spread는 es6부터 추가된
배열이나 오브젝트를 말그대로 나열해주는 도구이다.
const array = ["b ", "c ", "d "];
예로들어 b, c, d를 가진 배열 array이 있다고 하자.
array 값들을 가진 array2를 하나 더 만들려고 할때,
나열을 모른다면 이렇게 해야 할 것이다.
const array2 = ["a ", array[0], array[1], array[2], "e "];
하지만 spread를 안다면 이렇게 표현 가능하다.
const array2 = ["a ",...array, "e "];
코드
export default function App () {
const array = ["b ", "c ", "d "];
const array2 = ["a ",...array, "e "];
return (
<h1>{array2}</h1>
);
};
'웹개발(프론트)' 카테고리의 다른 글
position (0) | 2021.04.08 |
---|---|
border-radius (0) | 2021.04.07 |
삼항연산자 (0) | 2021.04.05 |
가상셀렉터로 icon 만들기 (0) | 2021.03.30 |
async / await (0) | 2021.03.29 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- CSS
- usecookies
- nodejs
- homebrew
- 웹접근성
- 아이콘
- 서버
- react
- useReducer
- 에러
- SVG
- 무료아이콘
- 이쁜코드
- 클릭
- 접근성
- 쿠키
- Hook
- 비동기
- async
- touchable
- 가상샐렉터
- dom
- Expo
- Redux
- switch
- proptype
- html
- visualcode
- 랜더링
- Router
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함