JS中怎么判断对象是否为数组的方法

原创
小哥 3年前 (2022-10-25) 阅读数 113 #js教程
文章标签 js
var arr2 = [{ abac : 1, abc : 2 }];
function isArrayFn(value){
  if (typeof Array.isArray === "function") {
    return Array.isArray(value);
  }else{
    return Object.prototype.toString.call(value) === "[object Array]";
  }
}
alert(isArrayFn(arr));// true
alert(isArrayFn(arr2));// true

摘自: https://www.cnblogs.com/heshan1992/p/6927690.htm

版权声明

所有资源都来源于爬虫采集,如有侵权请联系我们,我们将立即删除

热门