_.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
Did you know?
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#