Skip to content

Instantly share code, notes, and snippets.

window.test = {
a: 1,
b: 2
mbaer3000 / add-on-steroids.js
Created January 18, 2016 14:27
Partial function application with arbitrary depth
function add(x) {
// here's where it all starts, at the edge: add(x)
var sum = x;
// this is where the funk gets in: we're building a function that adds to
// the above sum and also provides a method to get to that sum, allowing
// to call the function arbitrarily often but also get to the sum,
// eventually. As in add(1)(2)(3)(4)(5).get()
var result = function(x) {