Optional parameter in Javascript function and default value by NicholasPhillips December 12, 2014 var myfunc = function(optional) { if (typeof optional == “undefined”) { optional = “default value”; } alert(optional); } Tags:functionjavascriptoptional