Created
January 20, 2019 06:24
-
-
Save ilagnev/4da26f95622d066e6a567c89096815e3 to your computer and use it in GitHub Desktop.
function to get objects with default values in es2015 style
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
| const createUser = ({ | |
| userName = 'Anonymous', | |
| avatar = 'anon.png' | |
| } = {}) => ({ | |
| userName, | |
| avatar | |
| }) | |
| // {userName: 'echo', avatar: 'anon.png'} | |
| createUser({ userName: 'echo' }) | |
| // {userName: 'Anonymous', avatar: 'anon.png'} | |
| createUser() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment