1

What is the most efficient way to clone a primeNG tree object which have Circular Structure? I've done things like

  1. obj = JSON.parse(JSON.stringify(o)); //but JSON.stringify() not working for Circular Structuure.
  2. var newObject = jQuery.extend(true, {}, oldObject);
  3. let newObject = this.copyObj(oldObject); copyObj(obj) { // This is done because we need a copy of list, without this code it will copy a ref which will update file badges on create screen without add button click return [obj[0]]; }
  4. let newObject = Object.assign({}, oldObject);

But all this method Copy Object ByReference not ByValue

Paresh Gami
  • 4,777
  • 5
  • 23
  • 41

0 Answers0