Setting default parameter to a function in javascript

0

Default parameters in function comes handy for developers in cases where most of the time a certain parameter value is used.

Let’s take an example of displaying a statement with function. We will first create a function name mobile that takes two parameter viz. os (operating system like Android or IOS  ) and memory (Inbuilt or Expandable).

A normal function with two parameter for displaying the statement based on those parameter  is given below.

Now let’s assume that the mobile has a default Inbuilt memory. So now we have to set the memory default value (default parameter) as Inbuilt.

Some parts of the code has been taken from here.

Share.
 

About Author

Entrepreneur & Dreamer

I am a passionate Software Professional, love to learn and share my knowledge with others.

Software is the hardware of my life.

Leave A Reply

CommentLuv badge

Get more stuff like this
in your inbox

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.