Skip to content

Instantly share code, notes, and snippets.

@amiller
Created November 26, 2013 03:38
Show Gist options
  • Save amiller/7653125 to your computer and use it in GitHub Desktop.
Save amiller/7653125 to your computer and use it in GitHub Desktop.
function g0() { return 0; }
function g1(a1) {
return a1;
}
function g2(a1,a2) {
return a1 + a2;
}
function g3(a1,a2,a3) {
return a1 + a2 + a3;
}
function f(a1,a2,a3,a4,a5,a6,a7) {
if (a1 === undefined) return g0();
if (a2 === undefined) return g1(a1);
if (a3 === undefined) return g2(a1,a2);
return g3(a1,a2,a3);
}
console.log(['f(1)', f(1)]);
console.log(['f(2,3)', f(2,3)]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment