0

I am having trouble to copy an array of objects using Lodash.

Please see the code,

var freshSlots = _.clone(this.bookingSlots);
console.log(freshSlots) // It prints the new changed copy
this.bookingSlots=this.bookingSlots[0].booked=true // here I am running some loops and changing the property values of this.bookingSlots

As you can see, this cloning is happening by reference that's why I never get the old copy. How can I get the old copy by values?

Thank you.

Hkm Sadek
  • 2,987
  • 9
  • 43
  • 95

0 Answers0