Like any kind of apps, JavaScript apps also have to be written well.

Otherwise, we run into all kinds of issues later on.

In this article, we’ll look at ways to improve our JavaScript code.

Optional Arguments

Arguments of a function can be anything in JavaScript.

We can have optional arguments.

If they aren’t passed into a function, then they’re undefined .

We can provide a default value for parameters that may be undefined .

For example, we can write:

function f(x = 1) {
  return x;
}

Then x ‘s default value 1.

If no value is passed in, then it’s 1.

#javascript #programming #web-development #software-development

Arguments and Parameters in Javascript
2.05 GEEK