How is that even possible that the value of widgets and newWidgets are same.
My program . look like this
var widgets = [{
    id: "1",
    title: 'title'
  },
  {
    id: "2",
    title: 'title2'
  },
  {
    id: "3",
    title: 'title3',
    children: [{
      id: "4",
      title: 'title4'
    }, {
      id: "5",
      title: 'title5',
      children: [{
          id: "6",
          title: 'title6'
        },
        {
          id: "7",
          title: 'title7'
        }
      ]
    }],
  },
  {
    id: "9",
    title: 'title9',
  }
]
var findAllObjectOnArray = function(obj) {
  for (var key in obj) {
    obj[key].newTitle = "newTitle" + key;
    if (obj[key].hasOwnProperty("children")) {
      findAllObjectOnArray(obj[key].children);
    }
  }
  return obj;
}
console.log(widgets)
let newWidgets = findAllObjectOnArray(widgets);
console.log(newWidgets);ANy possible reason why console.log(widgets) and console.log(newWidgets) showing same result
 
    