0

I have an object as:

secondObject {
  name: value,
  userName: value,
  userId; value,
}

And I have a pre-defined Model whose instance I am creating as

let modelObject: Model.

The Model is defined as follows

{
  userName,
  userId
}

Basically both models have some common fields and same data type since the first object I have described is just an extension of a join query on the Model and some other data, resulting into having an object that has all the fields of the Model plus some more.

What I want to do is:-

let thirdObj: Model;
obj = object

The 'object' above is one with the extra fields

and NOT get the obj as:

{
      name: null,
      userName: value,
      userId; value,
    }

But instead GET:

{
userName: value,
userId: value
}

Any ideas how I can achieve this?

Idan
  • 5,405
  • 7
  • 35
  • 52
Tony
  • 152
  • 2
  • 15
  • 1
    Possible duplicate of [Update an object with matching properties and ignore new properties](https://stackoverflow.com/questions/51206836/update-an-object-with-matching-properties-and-ignore-new-properties) –  Jul 30 '18 at 10:32
  • Try spead operator – Abin Thaha Jul 30 '18 at 10:38

0 Answers0