Copying
Using the spread operator
There are no mutations with this code.
const oldArray = ['Mon', 'Tue', 'Wed'];
const newArray = [...oldArray]
Using the slice method
const oldArray = ['Mon', 'Tue', 'Wed'];
const oldArray.slice();
© 2023 Better Solutions Limited. All Rights Reserved. © 2023 Better Solutions Limited TopPrevNext