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();



© 2020 Better Solutions Limited. All Rights Reserved. © 2020 Better Solutions Limited TopPrevNext