Created
March 28, 2018 12:33
-
-
Save buggy/3df16ad87751a9cb6eeacad3a909a9e9 to your computer and use it in GitHub Desktop.
Default options with the Javascript spread operator
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
function myfunc(options) { | |
const defaultOptions = { | |
min: 0, | |
max: 10, | |
}; | |
const finalOptions = { | |
...defaultOptions, | |
...options, | |
}; | |
console.log(finalOptions); | |
} | |
myfunc({}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment