How do you check if a variable is an array in JavaScript ?

Posted by Andy McCluggage on Stack Overflow See other posts from Stack Overflow or by Andy McCluggage
Published on 2009-04-20T09:02:59Z Indexed on 2010/04/06 10:23 UTC
Read the original article Hit count: 184

Filed under:
|
|

I would like to check whether a variable is either an array or a single value in JavaScript.

I have found a possible solution...

if (variable.constructor == Array)...

Is this the best way this can be done?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about variables