Remove use of instanceof

Add an isArray utility method and use it instead of instanceof