I'm building a complex object in Javascript and I want to expose an iterator over an internal collection of the object.
The only way I can think of is the usual way of exposing iterators in prototype.js :
customObject.each(function (item) { ... })
with the provided function being called by the iterator each for every item in the collection, one after the other.
Do you know any other reliable way? Maybe a way that would let users use the usual foreach construct?