How to combine two objects of different types in TypeScript?

Initially, I define

a = {};
b:any;

After some processing i get

a = {p:"1", f:"2"}

b = {"3","5"}

I tried to merge these two results. I tried

cart = [];

cart.push(this.a);
cart.push(this.b);
console.log(this.cart);

and get the result as below:

{p: "1", f: "2"}

{b: ["3","5"]}

I want the result like:

a ={p:"1", f:"2", b:"3","5"}

How can I achieve the above.



Read more here: https://stackoverflow.com/questions/64950262/how-to-combine-two-objects-of-different-types-in-typescript

Content Attribution

This content was originally published by An student at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: