Last active
October 10, 2019 15:36
-
-
Save townivan/7a2b3dca7854fd5dbf541b571c82b59e 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
/** | |
* Be amazed at this use for destructuring | |
* If you pass args as an obj instead of | |
* distinct values like f('red','male',23) | |
* You can use destructuring in the function | |
* to get what you want without needing to | |
* figure out which position it should be in! | |
*/ | |
function f( {name, age} = {}){ // destructure the received {} to name and age. | |
console.log('age:',age); // age: 23 | |
} | |
f({color:'red', gender:'male', age:23}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment