Skip to content

Instantly share code, notes, and snippets.

View test.js
window.test = {
a: 1,
b: 2
}
@mbaer3000
mbaer3000 / add-on-steroids.js
Created Jan 18, 2016
Partial function application with arbitrary depth
View add-on-steroids.js
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) {