作者:小胖儿的大城 from: http://fins.iteye.com/blog/315643
从
http://blog.360.yahoo.com/blog-TBPekxc1dLNy5DOloPfzVvFIVOWMB0li?p=916
学来一招, 判断一个js对象是不是数组
function isArray(o) {
return Object.prototype.toString.call(o) === '[object Array]';
}
原文如下 :
写道
The Miller Device
The JavaScript language currently does not provide a good way to distinguish between objects and arrays. The typeof operator is broken: It identifies arrays as objects. Comparing a value's constructor property doesn't work because arrays created in a different frame will have a different constructor. There are do-it-yourself tests for arrayness, but they are complicated and unreliable.
Mark Miller of The Google, by closely reading the ECMAScript standard, has discovered a simpler, more reliable test.
Object.prototype.toString.apply(value) === '[object Array]'
分享到:
相关推荐
新学到的一招之单空间绑多域名实现提速
浙江省新学考名校交流2020-2021学年高一下学期6月模拟卷地理试题 .docx
凤凰新学案高中语文_选修《史记》选读(教师用书).doc
我新学的,做的这个flash不是很棒,大家捧捧场
2020届新学考山东省高三政治模拟信息试题一.pdf
Linux命令很多。一下子记不住,强背也记不长久。所以我就先到一个办法。把每天新学到的命令放到这篇日志里面。方便以后查看,做个小小的备忘录。呵呵,what a good idea!
新学学校工作计划.pdf
秋季新学自我介绍精选.doc
2022九月新学年初一开学第一课教案多篇_教师工作计划.pdf
金版新学案高中历史一轮复习日本明治维新和戊戌变法课件人民版选修.pptx
金版新学案高三英语一轮复习 第二单元 同步测试 外研陕西专版选修8 .doc
中学新学年度工作思路汇报.doc
新学高一分班考试化学试卷.pdf
新学上期学校工会工作计划.pdf
NULL 博文链接:https://1185407601.iteye.com/blog/2257898
练习36异或模式制作的小动画本例知识点一句话讲解新学知识使用.pdf
金版新学案高三数学一轮复习平面向量的数量积文全国重庆专版PPT学习教案.pptx
班委新学年度的工作计划书.doc
北京市昌平区新学道临川学校2020学年高二语文下学期第一次月考试题.doc
北京市昌平区新学道临川学校2020学年高二语文上学期第一次月考试题.doc