Skip to content

Instantly share code, notes, and snippets.

@fabien-d
Created September 22, 2015 16:27
Show Gist options
  • Save fabien-d/213abc0ae3d14da8d8f1 to your computer and use it in GitHub Desktop.
Save fabien-d/213abc0ae3d14da8d8f1 to your computer and use it in GitHub Desktop.
Nested Object.assign calls formatting
let object = {
key: {
subkey: 'value',
status: 'STATUS'
}
};
// compact
Object.assign( {}, object, { key: Object.assign( {}, object.key, { status: 'PENDING' } ) } );
// expanded
Object.assign(
{},
object,
{
key: Object.assign(
{},
object.key,
{ status: 'PENDING' }
)
}
);
// mixed
Object.assign(
{}, object, {
key: Object.assign(
{}, object.key, {
status: 'PENDING'
}
)
}
);
// other?
@ohmyjersh
Copy link

Thank you, just saved me a headache!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment