06 Mar

Object or 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]

One thought on “Object or Array

Leave a Reply

Your email address will not be published. Required fields are marked *