There’s a simpler solution for the problem with context: jQuery.fn.forEach = Array.prototype.forEach || [fallback];
Examples of the fallback implementation: https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference:Objects:Array:forEach#Compatibility http://code.google.com/p/vice-versa/source/browse/trunk/src/Array.js 2. Reuse Array’s forEach method: On Aug 7, 3:43 pm, tarini <tarin...@gmail.com> wrote: > Hi guys, for some days I've got a question about usage of scope inside > jquery iterators like each. > > Do you really think that referring to current item using "this" is a good > thing? I think it's limitation for who use jquery in object oriented > approach. > I think it will be better passing current item to closure as an arguments... > > $("div").each(function(div, index) { > console.log(div); //current item > console.log(index); //current index > console.log(this); // window or custom scope > > }); > > -- > everything has got to end sometime we were satellites drifting off into > space > vega 4 - burn and fade away --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "jQuery Development" group. To post to this group, send email to jquery-dev@googlegroups.com To unsubscribe from this group, send email to jquery-dev+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/jquery-dev?hl=en -~----------~----~----~----~------~----~------~--~---