Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.