I was wondering if anyone knows whether the spread operator
cosnt newArray = [...oldArray];
makes the lodash method
const newArray = _.clone(oldArray);
obsolete?
Or more importantly if either method is more efficient?
*Note this is a shallow clone, just want object references in a new array.
Thank you!
It looks like clone
is faster than the spread operator: https://www.measurethat.net/Benchmarks/ShowResult/81691 .
However, as javascript in an expensive resource to process, it's probably not a good idea to add a library to do what vanilla js can do perfectly well.