Move 'typeOf' function to util module.
Throw is a value passed to numItems is not an object or an array.