Wouldn't using typeof on an array return "object"? I think you have to use Array.isArray...