// (arr: 원본배열, index: 삽입위치, newItem: 삽입할_아이템) const insert = (arr, index, newItem) => [...arr.slice(0, index), newItem, ...arr.slice(index)];
그냥 원하는 위치를 기준으로 잘라서 그 사이에 넣으면 됨
const items = [1, 2, 4, 5]; // insert the number 3 at index 2: insert(items, 2, 3); // [1, 2, 3, 4, 5]