美文网首页
判断是否是数组

判断是否是数组

作者: 秀萝卜 | 来源:发表于2021-01-10 20:01 被阅读0次
  检验是否是数组
  let a = [1,2,3]
  Object.prototype.toString.call(a) === '[object Array]';//true

  检验是否是函数
  let b = function () {};
  Object.prototype.toString.call(b) === '[object Function]';//true

  检验是否是数字
  let c = 1;
  Object.prototype.toString.call(c) === '[object Number]';//true


判断数组方法   Array.isArray() //在ES5开始支持
let a = [1,2,3]
Array.isArray(a);//true

相关文章

网友评论

      本文标题:判断是否是数组

      本文链接:https://www.haomeiwen.com/subject/yunzsktx.html