DEV Community

Discussion on: How to Deep Clone an Array in JavaScript

Collapse
 
ocdalex profile image
Alex Walker

Nicely explained. Another quirk of JavaScript I'l know to look out for, but your JSON solution is simple to remember.

Collapse
 
samanthaming profile image
Samantha Ming

JSON is your quick and dirty solution. For a more robust solution, I’d go with Lodash 🙂

Collapse
 
shayd16 profile image
Shayne Darren • Edited

I don't think this is javascript specific? And no, it's not a quirk.
Even Java(and most other languages) copies non-primitive data types by reference.
Maybe I misunderstood your comment though.

Collapse
 
ocdalex profile image
Alex Walker

I'm a primarily a PHP developer so everything about JavaScript is quirky to me. :-)

Thread Thread
 
shayd16 profile image
Shayne Darren

Let's just pretend I left the obligatory, "But php has a,b,c,d....x,y,z quirks and javascript is so much better" ;)