Supposedly, there is a deeper problem (see this thread at Google groups) that is that foreach treats the object as a dictionary of parameters, not as the collection to iterate.
My best solution so far is to combined foreach in Object.keys(myobject) and 'with' binding context.