Skip to content

Instantly share code, notes, and snippets.

@ericrrichards
Created November 13, 2012 14:49
Show Gist options
  • Select an option

  • Save ericrrichards/4066113 to your computer and use it in GitHub Desktop.

Select an option

Save ericrrichards/4066113 to your computer and use it in GitHub Desktop.
Javascript default params
function Foo( a, b, c, d, e ){
a = typeof a !== 'undefined' ? a : 0;
b = typeof b !== 'undefined' ? b : 0;
c = typeof c !== 'undefined' ? c : 0;
d = typeof d !== 'undefined' ? d : 0;
e = typeof e !== 'undefined' ? e : 1;
return (a + b + c + d ) / e;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment