3 ms·
Closures and stuff are great, but for the sake of being ornery: function Cook( i1, i2, f ) { alert("get the " + i1); f(i1); f(i2); }
by wk_end 2y ago
Closures and stuff are great, but for the sake of being ornery:
function Cook( i1, i2, f )
{
alert("get the " + i1);
f(i1);
f(i2);
}
Cook( "lobster", "water", PutInPot );
Cook( "chicken", "coconut", BoomBoom );
(or worse)
Cook("lobster",
"water",
function(x) { alert("pot " + x); }
);
Cook("chicken",
"coconut",
function(x) { alert("boom " + x); }
);
This to me looks like a great example of The Wrong Abstraction. You're removing a tiny bit of code duplication at the cost of creating a weird, hard-to-read, inflexible, limited-use helper; he's taken something straightforward and turned it into, honestly, a bit of a hash.