JavaScript does not support argument arguments like this. Like many others, you can choose a default inside your function. A brief idiom for setting the default value:
arg = arg || default;
So in your case it will be:
remove_wrap = remove_wrap || false;
However, if your default value is false , you do not even need to set it. Since when this argument is not enough, its value will be of type undefined inside the function, and this value is already "false": you can directly use remove_wrap , as it is:
function display_message(bool, msg, remove_wrap) { var error = bool ? get_msg(msg, remove_wrap) : get_error_msg(msg, remove_wrap); $.fancybox(error, { autoDimensions: false, width: 450, height: "auto", transitionIn: "none", transitionOut: "none" }); }
Bonus: Please note that I also added var to the error variable (don't omit var if your true intention is to create a global variable). I also shortened the assignment with a triple expression. I also reformatted a fancybox call with a syntax that most people find more readable.
source share