Wants to update child array not parent

Hi all
I want to update child object not parent …

let devices1;
    devices.push({
      name:'Nikhil',
      place:'jammu',
      temp:'temp'
    })    
    devices1=devices;   
    for(let x of devices1){
      delete x.name;      
    } 
    console.log('devices1'+JSON.stringify(devices1)+'devices'+JSON.stringify(devices))      

dont want to update devices object

I’m not sure I am clear what you mean by “parent” and “child” here, but if you’re saying you want to modify devices1 without also having that change affect devices, then you must not do this:

devices1=devices;

That aliases both devices and devices1 to the same object. You can use something like Object.assign or lodash’s clone functions instead of orginary assignment.

hi
I tried the same Object.assign still not working but later I found angular 2 does object by reference while copying …

This has nothing whatsoever to do with Angular. It’s completely a JavaScript issue. Object.assign does only one level of cloning; if you need something deeper, use lodash.