I have a function that takes a dynamic object and returns an object in angular typescript:
  public clean(row: object): object {
    //[... what to do here ? ]
    return row;
  }
This function should be able to take an object of any model / interface
Let's hypothetically assume I have the following data that I am passing through the function:
  this.data = {
    property1: 1,
    property2: 'prop2',
    property3: 'prop3',
    property4: 'prop4'
  }
And I would like the function "Clean" above to return the following:
  this.data2 = {
    property1: 1,
    property2: 'prop2',
    property3: 'prop3'
  }
In other words, I would like to remove property4 each time.
However, I would like this.data to be immutable, meaning I don't want to overwrite it, but I would like to return the new model without overwriting the old one (which is what my issue is now, it keeps overwriting it).
How would I do it ? I've tried to use the following:
let data2 = this.data;
delete data2['property4'];
return data2;
However, it's overwriting this.data.
Thanks for the help!
 
    