Hi! I would like to know if there is an elegant way to test if an object is an array.
Example:
In the code above, the function is receiving an object that could be an array or not. The main reason I want to know if it is an array is because I want to use the length property. Do anyone know if there is a property in DOM to know if an object is an array so I can invoke the length property without error?Code:function ProcessObject(object) { //Test if it is an array. if(...) { for(int i=0; i < object.length; i++) { //object[i] ... } } else { //Don't process as an array. //object.value ... } }
Thanks a lot!
PS: I make it, in a not elegant way...![]()




Reply With Quote