JavaScript Snippets

Fixing the variable scope in looped closure constructs

function fix (fnc) {
    var args = Array.prototype.slice.call(arguments, 1);
    return function() {
        return fnc.apply(this, args);
    }
}