Skip to content

Instantly share code, notes, and snippets.

@psiborg
Created January 6, 2012 08:18
Show Gist options
  • Select an option

  • Save psiborg/1569652 to your computer and use it in GitHub Desktop.

Select an option

Save psiborg/1569652 to your computer and use it in GitHub Desktop.
JS Function Defaults
function say (name, agree) {
// provide default values
var name = name || "Fred";
var agree = (agree !== undefined) ? true : false;
}
say(); // Fred, false
say("Barney"); // Barney, false
say("Barney", "anything"); // Barney, true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment