-
[JavaScript] 배열 숫자 채우기JavaScript 2023. 2. 10. 15:06
0 to N
const array = Array.from(Array(N).keys()); const array = [...Array(10).keys()]
1 to N
const array = [ ...Array(N).keys() ].map( i => i+1); const array = Array.from(Array(N), (_, i) => i+1); const array = Array.from({ length: N }, (_, i) => i+1);
반응형'JavaScript' 카테고리의 다른 글
[JavaScript] Number + (undefined, null, false)와 NaN (0) 2023.04.25 [Javascipt] Clipboard API 사용 (0) 2023.03.04 [JavaScript] RTK Query: Automated Re-fetching (1) 2023.01.06 [JavaScript] 특정 요소에 따른 스크롤 자동 조정 : scrollIntoView() (0) 2023.01.03 [JavaScript] checkbox 체크 확인, select, radio 값 가져오기 (0) 2022.10.11