title: Is it me, or does John Resig's popular blog post on partial application not work?
body: <p>John Resig has a popular blog post on partial application: <a href="http://ejohn.org/blog/partial-functions-in-javascript/">http://ejohn.org/blog/partial-functions-in-javascript/</a> It's mentioned in many places, and has </p>
  
  <p>However, the code in the blog post doesn't work. Here it is:</p>
  
  <pre><code>Function.prototype.partial = function(){
    var fn = this, args = Array.prototype.slice.call(arguments);
    return function(){
      var arg = 0;
      for ( var i = 0; i &lt; args.length &amp;&amp; arg &lt; arguments.length; i++ )
        if ( args[i] === undefined )
          args[i] = arguments[arg++];
      return fn.apply(this, args);
    };
  };
  
  var delay = setTimeout.partial(undefined, 10);
  
  delay(function(){
    alert( "A call to this function will be temporarily delayed." );
  });
  </code></pre>
  
  <p>Now, if you try to run this in your console it'll work fine. However, if you try to use the delay function again, it won't work. Try to run this in your console after running the first segment:</p>
  
  <pre><code>delay(function(){
    alert( "This is a test" );
  });
  </code></pre>
  
  <p>Note that the second message doesn't appear - the first message does. Of course, if you remake the delay function, it works, but why on earth would you want to remake your partially applied function every time you use it?</p>
  
  <p>Now, given that this blog post is the second Google result for "partial application javascript" and seems to be fairly popular, I doubt that it's completely broken. On the other hand, tons of code samples and the popular Prototype.js library function in the way I'd expect - reusable partial application. His currying function, slightly higher up the page, works exactly the way I'd expect. Thus:</p>
  
  <ul>
  <li>Is John Resig's code incorrect?</li>
  <li>If it's not, why does his code force you to remake your partially applied function every time you want to use it?</li>
  </ul>