[Javascript] Array.prototype.fill()
const arr = Array(100).fill() console.log(arr); // [ undefined,undefined,undefined,undefined,undefined ...] console.log(arr.length); // 100 const arr = Array(10).fill('👍')// ['👍','👍','👍','👍','👍','👍','👍','👍','👍','👍'] 숫자만큼 1부터 숫자까지 배열 만들기 const arr2 = Array(10).fill().map((_, i) => i+ 1) console.log(arr2); // [1,2,3,4,5,6,7,8,9,10]
2022. 10. 9.