implementation of array foreach.toObject : in progress