Reputation: 1760
I have next code:
let otherObject = {stat: 1, pos: 3, ..... other parameters};
function someF() {
return {
valid: false,
otherObject,
};
}
this function return next object:
{
valid: false,
otherObject
}
but what I need is to get parameter of otherObject:
{
valid: false,
stat: 1,
pos: 3,
.....
}
Upvotes: 2
Views: 60
Reputation: 28414
You can use the spread operator:
let otherObject = {stat: 1, pos: 3};
function someF() {
return {
...otherObject,
valid: false,
};
}
console.log( someF() );
Upvotes: 1