Object Or Array Check in JavaScirpt
Test whether an object is an object or an array
if(Object.prototype.toString.apply(arr) === '[object Array]') alert("Array")
Test whether an object is an object or an array
if(Object.prototype.toString.apply(arr) === '[object Array]') alert("Array")
Find whether the given variable is an object,or is an Array?
function isArray(testObject) {
return testObject && !(testObject.propertyIsEnumerable('length')) && typeof testObject === 'object' && typeof testObject.length === 'number';
}
Original Page
[tags]javascript,object,array,type[/tags]