Best practices for JavaScript function parameters

  • The problem with passing an object as a parameter to a function is that it’s not clear what values you should put into it.
  • One common thing in FP is to partially apply your functions, which is much harder to do if your function takes its parameters as an object.
  • While separate parameters are a good starting point, we run into trouble as soon as the function has optional parameters.
  • For functions with a single optional parameter, the solution is simple:

    Best practice: optionals come last

    However, if we have more than one optional parameter, the problem is… what if we only need to pass one optional parameter?

  • You can pass in parameters easily as an object, but the properties for the object can be easily seen from the function’s signature.

From time to time, people ask things like “should I use objects to pass function arguments”. I’m sure you recognize the pattern, as it’s common with many libraries:
Continue reading “Best practices for JavaScript function parameters”


  • The starter kit includes a working example app that calculates fuel savings.
  • The starter kit includes a working example app that puts all of the above to use.
  • Working example app – The included example app shows how this all works together.
  • Once you’re comfortable with how the example app works, you can delete those files and begin creating your own app .
  • Delete the example app files.

Read the full article, click here.

@DaveOrDead: “Very impressed with this React Redux starter kit by @housecor comprehensive and well documented #reactjs”

react-slingshot – React + Redux starter kit with Babel, hot reloading, testing, linting and a working example app, all built in