Function that filters undefined items out from an array.