> For the complete documentation index, see [llms.txt](https://april.gitbook.io/learning-js/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://april.gitbook.io/learning-js/chapter-8./8.2/8.2.6.md).

# 8.2.6 특정 값으로 배열 채우기

### fill 메서드

* ES6에 도입한 새 메서드
* 정해진 값으로 배열을 채움
* 배열의 일부만 채우려는 경우? 시작 인덱스와 끝 인덱스를 지정하면 됨
* 음수 인덱스 사용 가능

```javascript
const arr = new Array(5).fill(1); // [1, 1, 1, 1, 1]
arr.fill("a"); // ["a", "a", "a", "a", "a"]
arr.fill("b", 1); // ["a", "b", "b", "b", "b"]
arr.fill("c", 2, 4); // ["a", "b", "c", "c", "b"]
arr.fill(5.5, -4); // ["a", 5.5, 5.5, 5.5, 5.5]
arr.fill(0, -3, -1); // ["a", 5.5, 0, 0, 5.5]
```
