Fix issue when array is undefined

This PR is to avoid error when array is undefined. lodash does not cause error in this case.