When dealing with a function that in its definition accepts several arguments...
function f(foo, bar, baz){ ... };
...it's easy accidentally misplacing the arguments in the function call:
//'baz' is being passed as argument to 'bar' parameter
f(foo, baz, bar);
function f(foo, bar, baz){ ... };
That said, what I do when writing a code with a given function that I keep changing by adding more and more parameters in its definition (I'm the one writing both the function definition and the function calls) is using a mix of property shorthand and destructuring, so I don't need to be worried memorising the order of the parameters, which is handy when we have lots of them:
//this will work, regardless the order
f({bar, foo, baz});
function f({foo, bar, baz}){ ... };
Question: will that strategy always work? That is, will it work for any kind of type (primitives, arrays, dates, sets, maps, functions etc...)?