Associating unique properties to anonymous functions in JavaScript
<p>What's a standard way of associating unique properties to anonymous JavaScript functions while creating them so that these properties can be accessed within the functions themselves when they are executed (i.e. run time)?</p>

<p>A scenario is this:</p>

<p><em>Say I have events which I want to bind to dynamically generated anonymous functions.</em></p>

<pre><code>var events = ['connect','disconnect','error','connect_failed'];

for(a in events){
  var handler = function(){
     // console.log(arguments.callee.custom); // Not reliable 'cos callee is supposedly deprecated
     console.log('&lt;event-name&gt;');
  };
  handler.custom = events[a];
  $(window).on(events[a],handler);
}
</code></pre>

<p>Since using <strong>arguments.callee</strong> is deprecated and not guaranteed to be optimal on all platforms. What's the recommended way of achieving something similar to this?</p>
