Skip to content

Instantly share code, notes, and snippets.

@TravelingTechGuy
Last active January 12, 2023 19:22
Show Gist options
  • Save TravelingTechGuy/0c98b96bb09c401e7bca577ead9482d1 to your computer and use it in GitHub Desktop.
Save TravelingTechGuy/0c98b96bb09c401e7bca577ead9482d1 to your computer and use it in GitHub Desktop.
Demonstrates taking an object parameters, with default values
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