Last active
January 12, 2023 19:22
-
-
Save TravelingTechGuy/0c98b96bb09c401e7bca577ead9482d1 to your computer and use it in GitHub Desktop.
Demonstrates taking an object parameters, with default values
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
let foo = ({param1 = 1, param2 = 2, param3 = 3} = {}) => { | |
return (param1 + param2) / param3; | |
}; | |
console.log(foo()); //returns 1 | |
console.log(foo({param3: 1})); //returns 3 | |
console.log(foo({param1: 7, param2: 2})); //returns 3 | |
console.log(foo({param1: 6, param3: 2})); //returns 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment