728x90 반응형 전체 글372 JavaScript) 문자 반복으로 문자열 만들기 Array(11).join("a") //"aaaaaaaaaa" "a".repeat(10) // "aaaaaaaaaa" 2022. 4. 3. JavaScript) 배열 평탄화 - 2차원 배열을 1차원으로 const arr = [1,2,[3,4],[5,6]]; const useReduce = arr.reduce((acc,items)=>{ return acc.concat(items); },[]); const useflat = arr.flat(); const useConcat = [].concat(...arr); console.log(useReduce); console.log(useFlat); console.log(useConcat); 2022. 4. 3. JavaScript) cannot convert undefined or null to object undefined or null과 {}, [] 는 다르기 때문에 따로 처리를 해줘야 함 {}와 []는 object array만 구분하고 싶을 때에는 Array.isArray()를 사용해야한다 2022. 4. 3. 알고리즘) 재귀 - 피보나치 수열 피보나치 수열 앞의 두 수의 합이 다음 항인 수열 0 1 1 2 3 5 8 13 피보나치 수열을 코드로 구현 피보나치 수열의 n 번째 값을 구하는 함수 function fibonacci(n) { if ( n 2022. 3. 28. 이전 1 ··· 10 11 12 13 14 15 16 ··· 93 다음 728x90 반응형