Effective deep copy of javaScript objects

Posted on

Sometimes one needs to copy a js object without any possible links to other objects, so keep it in mind:

newObj = JSON.parse(JSON.stringify(obj)) 

is 4 (four) times faster than

newObj = jQuery.extend(true, {}, obj)

Unfortunately it’s inappropriate for objects with functions with it

Leave a Reply

Your email address will not be published.