Using spread syntax, we have just achieved an operation that would have been more complex and more verbose had we used traditional methods.
When I try to use the traditional method and try to copy one array into another like this:
let thisArray = ['sage', 'rosemary', 'parsley', 'thyme']; console.log("thisArray before thatArray: " + thisArray) // Old way let thatArray = ['cilantro',thisArray.slice(0,3),'coriander'] console.log("thatArray: " + thatArray)
So, how does it is different from
let thatArray = ['basil', 'cilantro', ...thisArray, 'coriander']; ?
And how the modern way(spread operator) is better than the traditional version(slice, as both OUTPUT the same result)?