Looking for an Argument

In JavaScript, the arguments object is created when a function is invoked. It is an array-like object (read: it has numerical indices) of all the items passed in to the function. It contains all arguments even if they weren't formally declared. Arguments belongs to the local scope and is not accessible outside the function.

In recursive functions, where the same function is called repetitively, arguments refers to the most recent invocation of the function. If a parameter named 'arguments' is formally declared, the arguments object is not created. The arguments object has as much in common with objects as it does with arrays.

This is a console.dir of an empty array.
Array Object This is a console.dir of an arguments 'array.'
Arguments Object

You can call array methods on the arguments object by using call or apply.

var args = Array.prototype.slice.call(arguments);

This is not recommended because it prevents optimization. The preferred method is to iterate through arguments and put them into an array (or other data type). You could use a for..in loop but arguments has numerical indices so it is logical to use a for with semicolons loop instead.

var args = [];  
for (var i = 0, count = arguments.length; i < count; i++) {  
    args.push(arguments[i]);
} 

There are several reasons why you might want to use the arguments array-like object. It allows you to accomodate an unknown number of variables. You can also use it as a string formatter. As Angus Croll mentions, you can use the arguments object combined with Regex to replace symbols with provided data.

You can also concatenate arguments objects together to create a combined arguments array. The function below binds the passed function to the passed context. You can see arguments has been pushed into an array in both functions and concatenanted so that the bound function is run with all the correct arguments.

var bind = function(func, context) {  
  var prevArgs = [];
  for (var i = 1, count = arguments.length - 1; i < count; i++) {
    prevArgs.push(arguments[i]);
  }
  return function() {
    var args = [];
    for (var i = 0, count = arguments.length; i < count; i++) {
      args.push(arguments[i]);
    }
    args = prevArgs.concat(args);
    return func.apply(context, args);
  }
};