an prototype extend function for Object and Array iteration