-
-
Save whoisryosuke/85198a6af12cccb8cd448029fdbaf6f2 to your computer and use it in GitHub Desktop.
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
const user2 = { | |
id: 200, | |
name: 'Vince Noir' | |
} | |
const user4 = { | |
id: 400, | |
name: 'Bollo', | |
quotes: ["I've got a bad feeling about this..."] | |
} | |
const setDefaults = ({ quotes = [], ...object}) => | |
({ ...object, quotes }) | |
setDefaults(user2) | |
//=> { id: 200, name: 'Vince Noir', quotes: [] } | |
setDefaults(user4) | |
//=> { | |
//=> id: 400, | |
//=> name: 'Bollo', | |
//=> quotes: ["I've got a bad feeling about this..."] | |
//=> } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment