Last Updated: February 25, 2016
·
3.967K
· benkitzelman

_.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)); 

2 Responses
Add your response

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 ·