An Interest In:
Web News this Week
- April 19, 2024
- April 18, 2024
- April 17, 2024
- April 16, 2024
- April 15, 2024
- April 14, 2024
- April 13, 2024
October 24, 2021 12:38 pm GMT
Original Link: https://dev.to/martinkr/1-line-of-code-how-to-shallow-clone-an-array-38aj
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:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To