title: Understanding AngularJS function $arguments
body: <p>Starting to get into angular.js, I've seen a common pattern relating to arguments of callbacks.  An example is the <a href="https://github.com/angular-ui/ui-router" rel="nofollow">ui-router documentation</a>:</p>
  
  <pre><code>var myApp = angular.module('myApp', ['ui.router']);
  
  myApp.config(function($stateProvider, $urlRouterProvider) {
      // Do stuff with ui-router providers
  }):
  </code></pre>
  
  <p>But, from want I've seen, the <code>myApp.config</code> callback's arguments could be different and it would still behave as expected:</p>
  
  <pre><code>myApp.config(function(OtherProvider) {
      // Do stuff with provider from another service
  });
  </code></pre>
  
  <p>How does <code>myApp.config</code> know the difference?  Is there done weird magic introspection going on, or is there some basic JS concept that allows for this?  E.g. something like:</p>
  
  <pre><code>myApp.config = function(callback) {
      var providerNames = callback.argumentNames;
      var providers = this.findProviders(providerNames);
  };
  </code></pre>
  
  <p>Perhaps I'm too used to python, where this sort of feature would only be possible through some very scary hacks.</p>