copyWithin

Tags
변환
새로운 배열 생성
요약
배열의 일부를 얕게 복사한 뒤, 동일한 배열의 다른 위치에 덮어쓰고 그 배열을 반환합니다.
asd
arr.copyWithin(target[, start[, end]])
  • target자리에 start부터 end-1 요소로 덮어씌움.
const array1 = ['a', 'b', 'c', 'd', 'e']; // array1을 복사해서 0번째 자리에 3~(4-1) 인덱스 요소로 덮어씌움. console.log(array1.copyWithin(0, 3, 4)); // expected output: Array ["d", "b", "c", "d", "e"] // array1을 복사해서 1번째 자리에 3~끝 인덱스 요소로 덮어씌움. console.log(array1.copyWithin(1, 3)); // expected output: Array ["d", "d", "e", "d", "e"]