Possible Duplicate:
How do you check if a variable is an array in JavaScript?
How can I check if a variable is an array (so I can handle each arrayvalue) or a single arrayvalue?
How can I check if a variable is an array (so I can handle each arrayvalue) or a single arrayvalue? |
|||||||||||||||||||||
marked as duplicate by mellamokb, Joe, nrabinowitz, Lekensteyn, Quentin Oct 4 '11 at 20:57This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. |
|||||||||||||||||||||
|
From the MDN page for isArray which is part of the ECMAScript 5 standard:
In many cases, you can also just check to see if there is a .length property (this is often what jQuery does) because this will also accept any array-like object that isn't actually an array, but can be iterated like one. Obviously, if you have things that do have a .length property that you don't want treated like an array, this will get fooled by that situation so you have to know which you want:
|
||||
|