How can I check if an object is an array?
Asked 07 September, 2021
Viewed 1.9K times
  • 50
Votes

I'm trying to write a function that either accepts a list of strings, or a single string. If it's a string, then I want to convert it to an array with just the one item so I can loop over it without fear of an error.

So how do I check if the variable is an array?

30 Answer