Add isArrayOf(type, array) and refactored code.