In 2024, you can use structuredClone, majorly for arrays and objects. It provides a deep clone of the given value. For shallow copy you can use the above answer given by @xynon - https://stackoverflow.com/a/60460458/11410210, which I would suggest to use as per requirement.
structuredClone example usage:
const originalArray = [1, 2, 3];
const newArray = structuredClone(originalArray);
newArray.push(4);
console.log('originalArray', originalArray); // [1, 2, 3]
console.log('newArray', newArray); // [1, 2, 3, 4]