Created
September 22, 2015 16:27
-
-
Save fabien-d/213abc0ae3d14da8d8f1 to your computer and use it in GitHub Desktop.
Nested Object.assign calls formatting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you, just saved me a headache!