arrows and a proposed softCall

Rick Waldron waldron.rick at
Mon Jun 4 16:51:49 PDT 2012

On Mon, Jun 4, 2012 at 6:10 PM, Yehuda Katz <wycats at> wrote:

> snip

> jQuery.each(someArray, function(i, item) {
>   // this and item are the items in the Array
>   // i is the index
> });
> It's too late for jQuery to fix the order now. However, in the face of
> arrows or bound functions, we probably could detect a user intent to use
> `this` for their own purposes and use that as a signal to change the order.
> jQuery.each = function(array, callback) {
>   for (var i=0, l=array.length; i<l; i++) {
>     item = array[i];
>     if (isBound(callback)) { callback(item, i); }
>     else {, i, item); }
>   }
> };

As a relevant aside - If you're not referring to the current item of the
iterating list via |this|, you could just as easily use fat arrow w/
jQuery.each() today:


I don't know whether it makes sense for a brand-new API to be designed this
> way, but for APIs that presently make (possibly misguided) use of `this` in
> place of a first parameter, the new (user-initiated, not available in ES3)
> binding behavior provides a single shot at a better way forward.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list