Skip to content

Instantly share code, notes, and snippets.

@zfz
Created December 10, 2018 23:08
Show Gist options
  • Save zfz/807cfce4bb65b619129cdcee0e909e8f to your computer and use it in GitHub Desktop.
Save zfz/807cfce4bb65b619129cdcee0e909e8f to your computer and use it in GitHub Desktop.
> const _ = require('lodash');
> obj = {'a': {'b': [1,2,3]}}
{ a: { b: [ 1, 2, 3 ] } }
> obj1 = _.cloneDeep(obj);
{ a: { b: [ 1, 2, 3 ] } }
> obj1.a.b.push(4)
> obj
{ a: { b: [ 1, 2, 3 ] } }
> obj1
{ a: { b: [ 1, 2, 3, 4 ] } }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment