Javascript has real closures, so it's just: function foo(n) { return function (i) { return n += i } } Add semicolons to taste...