JSFiddle - React, Tailwind, and code Playground
JavaScript
const original = [1, 2, 3, 4];
const updated = Object.assign([...original], {1: 4, 3: 42});
console.log(updated); // [1, 4, 3, 42]
const original = [1, 2, 3, 4];
const updated = Object.assign([...original], {1: 4, 3: 42});
console.log(updated); // [1, 4, 3, 42]