Simple Example of JavaScript function Default value

Default value of an argument is very important when you are creating a function which will used many times in project, Its very simple in PHP programming, we just pass default value against parameter but in java script language does not work.We need check type and then set default value to variable in JavaScript.

PHP function with Default value

If you have same requirement in JavaScript the you could not define default value as PHP.

Simple Example of JavaScript Function same as above PHP

When you run above code you will get JavaScript error

Right way to Define Default Parameters in JavaScript Function