Skip to content

Instantly share code, notes, and snippets.

@fat
Created March 7, 2011 22:58
Show Gist options
  • Save fat/859445 to your computer and use it in GitHub Desktop.
Save fat/859445 to your computer and use it in GitHub Desktop.
make this better.
function __tailingFn () {
for (var i = arguments.length; i--;) {
if (typeof arguments[i] == 'function') {
var fn = arguments[i];
arguments[i] = undefined;
return fn;
}
}
}
@ded
Copy link

ded commented Mar 7, 2011

function __tailingFn () {
  for (var i = arguments.length; a = arguments[i]; i--) {
    if (typeof a == 'function') {
      var fn = a
      a = undefined;
      return fn;
    }
  }
}

@assertchris
Copy link

What is the point of unsetting the fn if this is all there is to __tailingFn? arguments ceases to exist after the function is exited anyways...

function __tailingFn () {
    var a, i = arguments.length;
    while (a = arguments[i--])
        if (typeof a == 'function') {
            return a;
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment