[Dojo-interest] What does the second argument to forEach do?

Dylan Schiemann dylan at dojotoolkit.org
Wed Jan 29 09:01:45 EST 2014

It's the equivalent of doing a lang.hitch call to preserve the context
on which the callback object is executed.

So you could do:

queryResult.forEach(callback, context);

which is the same as

queryResult.forEach(lang.hitch(context, callback));

which is roughly the same as


Most modern usage of Dojo APIs will use one of the latter two options,
as we have tried to move away from having APIs that build in their own
context parameter (for example, you will not see this option with
dojo/on, instead you should just use lang.hitch as needed).


on 1/29/14, 12:51 AM (GMT-07:00) Robert Mark said the following:
> Hi All,
> http://dojotoolkit.org/reference-guide/1.9/dojo/NodeList.html#foreach
> The second argument to forEach is identified as "thisObj"... and that's
> it. What does it do? Is this documented anywhere?
> Rob
> :)
> ________________________________________________________
> Dojo Toolkit: http://dojotoolkit.org/
> Tutorials: http://dojotoolkit.org/documentation/
> Reference Guide: http://dojotoolkit.org/reference-guide
> API Documentation: http://dojotoolkit.org/api
> Dojo-interest at mail.dojotoolkit.org
> To unsubscribe, visit: http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest

Dylan Schiemann
SitePen, Inc.
2014 Workshop schedule in the US, Canada, England and Switzerland:
SitePen Insider: http://sitepen.com/insider/

More information about the Dojo-interest mailing list