Array是包含在object对象中的。

解决方案 »

  1.   

    function chkArr(obj){
    if(!obj.hasOwnProperty("length")){
    alert("不是数组");
    return false;
    }
    return true;
    }
    因为Array都有length属性,所以没有length属性的肯定不是数组,但有的object可能也有length属性,所以这个函数还不能完全判断。
      

  2.   

    修改一下,这样更准确一些:
    function chkArr(obj){
    if(obj.hasOwnProperty("length")){
      if(obj.length!=0){
        if(obj[0]){return true;}else{return false;}
        return true;
      }
    }
    return false
    }
      

  3.   

    建议使用constructor 或.length
    因为hasOwnProperty 要求 版本 5.5,而constructor 要求 版本 2<script>
    function chkArr(o){return typeof(o.length)!="undefined"}
    function isArr(o){return o.constructor==Array}var arr=[1,2,3,4]
    var obj={1:2,3:4}
    alert(chkArr(arr))
    alert(chkArr(obj))
    alert(isArr(arr))
    alert(isArr(obj))
    </script>
      

  4.   

    未必哦array,是数组,没有什么疑问吧?集合也有length啊。alert(document.links.length);
      

  5.   

    <script>
    var aa = new Array();
    alert(aa instanceof Array); ///return true
    </script>
      

  6.   

    var a = new Array();
    var b = new Object();
    alert(delete a.length); // 显示false; 因为这个属性不可删除
    alert(delete b.length); // 显示true; 因为根本无此属性
      

  7.   

    <script>
    var aa = new Array();
    alert(aa instanceof Array); ///return true
    </script>还是这个有道理。