I am creating a complex object in Javascript, and I want to set an iterator over the internal collection of the object.
The only way I can think of is the usual way to expose iterators in prototype.js:
customObject.each(function (item) { ... })
with the provided function called by the iterator, each for each element in the collection, one after the other.
Do you know any other reliable way? Maybe this will allow users to use the usual foreach construct?
source
share