1

const obj1 = { food: 'pizza', car: 'ford' };
let obj2 = obj1;

In the above example, I want to do deep copy of obj1 in obj2 .

2
  • 1
    Is it JSON or is it a javascript object? Commented Dec 26, 2019 at 6:39
  • not sure why you want to deep-clone the object in your example? A shallow copy should work fine Commented Dec 26, 2019 at 6:42

1 Answer 1

0

use _.cloneDeep
https://lodash.com/docs/#cloneDeep

var objects = [{ 'a': 1 }, { 'b': 2 }];

var deep = _.cloneDeep(objects);
console.log(deep[0] === objects[0]);
// => false
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.