DEV Community

Discussion on: Self-Documenting Function Calls

Collapse
devdufutur profile image
Rudy Nappée • Edited on

In JS, maybe you could've use named parameters with object destructuring like that :

// definition
const searchRecipes = ({
   searchText = "",
   includeSpicy = true,
   onlyVegan = false,
   includeSponsoredResults = true
}) => {
   // do all the recipe-search magic here
};

// Call
searchRecipes({
   searchText: "linguine",
   includeSpicy: true,
   onlyVegan: false,
   includeSponsoredResults: true
})