_.clone is shallow
Underscore clone does not truly deep clone js objects.... one of the simplest and best performing way of cloning complex JS objects is still
var clone = JSON.parse(JSON.stringify(obj));
Written by Ben Kitzelman
Related protips
2 Responses
This is ridiculously simple. I wish I would have found this far sooner! Thanks for posting!
over 1 year ago
·
or, you know... use _.cloneDeep (lodash, which is nicer anyway)
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Underscore.js
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#