Opened 10 years ago

Last modified 10 years ago

#9399 closed enhancement

Alias forEach as each — at Version 1

Reported by: Les Owned by: anonymous
Priority: high Milestone: 1.4
Component: General Version: 1.3.0
Keywords: each, forEach Cc:
Blocked By: Blocking:

Description (last modified by bill)

Enhancement suggestion: alias the forEach method (wherever it's used) as each. This should make the code more compact. Note that both MooTools and jQuery use each().

Change History (1)

comment:1 Changed 10 years ago by bill

Description: modified (diff)

Hmm, according to http://docs.jquery.com/Utilities/jQuery.each and http://docs.jquery.com/Core/each, jquery's each() method is like dojo's every() method, in that if/when the callback function returns false, it breaks the loop.

Dojo's forEach() method is different in that it ignores the callback's return value.

Maybe it makes more sense to alias dojo.every to dojo.each, although I'm generally not a fan of aliases.

Note that Dojo's forEach() is named after Array.forEach in javascript.

Note: See TracTickets for help on using tickets.