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”

Next.Js – JavaScript Mantra – Medium

Next.Js —  Is it the next big thing in #JavaScript?:  by @arunoda #ReactJS

  • Just create a few files for pages in your app, and you are done.
  • For example, let’s say you need to create web app with two pages (Home page and About page).
  • It uses the file system as the router for your app.
  • You need to bring additional stuff which is needed for your app.
  • import React from ‘react’ import Header from ‘.

There are too many JS frameworks out there — we all know that.
But still, we see new JS frameworks every day. Next.js may not cure JS Fatigue, but it allows us to build web apps in JavaScript as we…
Continue reading “Next.Js – JavaScript Mantra – Medium”

Next.Js – JavaScript Mantra – Medium

Next.Js: Is it the next big thing in JavaScript? @arunoda  #JavaScript #Reactjs

  • Just create a few files for pages in your app, and you are done.
  • For example, let’s say you need to create web app with two pages (Home page and About page).
  • It uses the file system as the router for your app.
  • You need to bring additional stuff which is needed for your app.
  • import React from ‘react’ import Header from ‘.

There are too many JS frameworks out there — we all know that.
But still, we see new JS frameworks every day. Next.js may not cure JS Fatigue, but it allows us to build web apps in JavaScript as we…
Continue reading “Next.Js – JavaScript Mantra – Medium”