개발자 '쑥말고인절미'
[JS] fill() 메소드 본문
Array.prototype.filll()
- fill() 메소드는 배열의 시작 인덱스부터 끝 인덱스의 이전까지 정적인 값 하나로 채운다.
- fill(입력값, 시작 인덱스, 끝 인덱드-1);
- 예제
const array = [1, 2, 3, 4];
console.log(array.fill(0, 2, 4)); //출력 : [1, 2, 0, 0]
console.log(array.fill(5, 1)); //출력 : [1, 5, 5, 5]
console.log(array.fill(6)) //출력 : [6, 6, 6, 6]
참고링크
https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Array/fill
Array.prototype.fill() - JavaScript | MDN
fill() 메서드는 배열의 시작 인덱스부터 끝 인덱스의 이전까지 정적인 값 하나로 채웁니다.
developer.mozilla.org
'STUDY > Vue.js & Express.js & JS' 카테고리의 다른 글
[Vue.js] 컴포넌트 & Props (0) | 2022.09.01 |
---|---|
[Node.js] Node.js 개념 (0) | 2022.08.30 |
[에러] 'vue-cli-service'은(는) 내부 또는 외부 명령, 실행할 수 있는 프로그램, 또는 배치 파일이 아닙니다. (0) | 2022.08.19 |
[에러] Uncaught Error Error: Cannot find module 'http-errors' (0) | 2022.08.19 |
[JS] getMonth() 반환값에 1씩 차이발생?! (0) | 2022.07.14 |