Lets assume we have two objects. We need to combine them before saving into database.
Then below is the way we can do that in angular typescript.
Our first object is
const object1 = {
{
role: 'author',
status: 'Assigned',
assigned: Date.now().toString(),
updates: []
},
{
role: 'author',
status: 'Assigned',
assigned: Date.now().toString(),
updates: []
}
{
role: 'author',
status: 'Assigned',
assigned: Date.now().toString(),
updates: []
},
{
role: 'author',
status: 'Assigned',
assigned: Date.now().toString(),
updates: []
},
}
Then below is the way we can do that in angular typescript.
Our first object is
const object1 = {
{
role: 'author',
status: 'Assigned',
assigned: Date.now().toString(),
updates: []
},
{
role: 'author',
status: 'Assigned',
assigned: Date.now().toString(),
updates: []
}
{
role: 'author',
status: 'Assigned',
assigned: Date.now().toString(),
updates: []
},
{
role: 'author',
status: 'Assigned',
assigned: Date.now().toString(),
updates: []
},
}
Then we need to append another object into object1.
We have a new object called object2.
const object2 = {
role: 'author',
status: 'Assigned',
assigned: Date.now().toString(),
updates: []
};
Below is the way we can do that easily.
Object.assign(object1 , object2 );
Post a Comment
Post a Comment