Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
October 24, 2021 12:38 pm GMT

1 line of code: How to shallow clone an Array

const shallowClone = arr => arr.slice(0); 

Creates a shallow-copied clone of the provided array. Since it's a shallow copy, nested objects or arrays will be copied by reference, not duplicated.

Happy coding and consider to buy me a coffee

Photo by zoo_monkey on Unsplash


Original Link: https://dev.to/martinkr/1-line-of-code-how-to-shallow-clone-an-array-38aj

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To