Return to Snippet

Revision: 48506
at July 3, 2011 16:07 by anagaiyahoocom

Initial Code
if(typeof Array.isArray==="undefined") {
    Array.isArray = function(arg) {
        return "[object Array]";

Initial URL

Initial Description
This will check if object is an array object.

This will add isArray() method to Array native object. Can be used to check if passed in object is an array. Future ecmascript 5 will have this included. Can use this in the meantime.

Using instanceof Array does not work in certain versions of IE.


var arr = [1,2,3];

alert(Array.isArray(arr)); //displays as true

Initial Title
Check if javascript object is an Array

Initial Tags

Initial Language