-
-
Save zainfathoni/538a70d88268a7d5810543cb29e25eab to your computer and use it in GitHub Desktop.
Nested Object.assign calls formatting
This file contains hidden or 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