Created
March 12, 2019 02:04
-
-
Save ferfabricio/05a0964d25a616b9c93f6de83aaa8f47 to your computer and use it in GitHub Desktop.
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 createRequestOptions(options) { | |
const defaultParameters = { | |
url: 'devparana.org', | |
method: 'GET', | |
secure: true | |
} | |
return { | |
...defaultParameters, | |
...options | |
} | |
} | |
console.log(createRequestOptions({ url: 'portalmaringa.com' })) | |
// Resultado | |
// { url: 'portalmaringa.com', method: 'GET', secure: true } | |
console.log(createRequestOptions({ method: 'POST' })) | |
// Resultado | |
// { url: 'devparana.org', method: 'POST', secure: true } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment