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 16 Most Popular React Links So Far in 2016 — Cooper Press — Medium

The best of #ReactJS in 2016:

  • 2: React Storybook: A Tool for Building React Components Outside of Your App
  • An in-depth comparison of 3 React alternatives (Deku, Preact and Virtual Dom) and why they could prove useful for your next project.
  • React Native has opened up React to a whole new type of developer (and, conversely, mobile development to existing React developers.)
  • A look at Enzyme, a library for testing React components.
  • Wireframe basic React components and download a skeleton project for Express or Hapi in one click.

Read the full article, click here.

@ReactiveConf: “The best of #ReactJS in 2016:”

We’ve looked through the stats for the 20 issues of JavaScript Weekly published so far in 2016 and have collected together the most popular…

The 16 Most Popular React Links So Far in 2016 — Cooper Press — Medium