Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

use Array.apply(null, arguments)

  • Loading branch information...
commit 66c8033cdd5d7a7ceee785e970bff7e08d943482 1 parent 37b6e95
@tj tj authored
Showing with 1 addition and 1 deletion.
  1. +1 −1  index.js
2  index.js
@@ -55,7 +55,7 @@ exports.__defineGetter__('currentNamespace', function(){
(express.router || express.Router).methods.concat('del').forEach(function(method){
var orig = app[method];
exports[method] = function(){
- var args =
+ var args = Array.apply(null, arguments)
mikepb added a note

Though it would not be a valid argument to the wrapped functions, Array.apply() doesn't work with a single number argument:

function toArray(){
  return Array.apply(null, arguments);

console.dir(toArray(2)); // returns array of undefined of length 2
console.dir(toArray(3)); // returns array of undefined of length 3
@tj Owner
tj added a note

ah right it takes a length too. fine for this use-case but I'll revert anyway

mikepb added a note

yes, oh all the fun ways to use Array

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
, path = args.shift()
, fn = args.pop()
, self = this;
Please sign in to comment.
Something went wrong with that request. Please try again.