How to copy all items from one array into another with JavaScript?

To copy all items from one array into another with JavaScript, we use the spread operator.

For instance, we write

const objArray = [
  { name: "first" },
  { name: "second" },
  { name: "third" },
  { name: "fourth" },
];
const clonedArr = [...objArray];

to use the spread operator to spread the objArray entries into a new array by copying each entry.