js--判断一个对象是否为数组

function isArray(obj){
    return Object.prototype.toString.call(obj) == "[object Array]";
}

  不能用instanceof 和 constructor来判断,原因参考:http://perfectionkills.com/instanceof-considered-harmful-or-how-to-write-a-robust-isarray/

 

posted @ 2013-02-13 12:02  GM_Lv  阅读(1142)  评论(0编辑  收藏  举报