Optional Parameter In Javascript Function And Default Value
Join the DZone community and get the full member experience.
Join For Free// description of your code here
VÃa Alexander Kirk
var myfunc = function(optional) {
if (typeof optional == "undefined") {
optional = "default value";
}
alert(optional);
}
JavaScript
Opinions expressed by DZone contributors are their own.
Comments