Skip to content

Instantly share code, notes, and snippets.

@torifat
Created June 17, 2011 19:23
Show Gist options
  • Save torifat/1032103 to your computer and use it in GitHub Desktop.
Save torifat/1032103 to your computer and use it in GitHub Desktop.
Optional Parameter in JavaScript
function foo(optional) {
if (optional === undefined) optional = "default";
}
function foo(optional) {
if(typeof(optional) == "undefined") optional = "default";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment