https://stackoverflow.com/questions/4775722/check-if-object-is-an-array

One of the weird behaviour and spec in Javascript is the typeof Array is Object.

You can check if the variable is an array in couple of ways:

var isArr = data instanceof Array;
var isArr = Array.isArray(data);

But the most reliable way is:

isArr = Object.prototype.toString.call(data) == '[object Array]';

Since you tagged your question with jQuery, you can use jQuery isArray function:

var isArr = $.isArray(data);

Why does typeof array with objects return “Object” and not “Array”?的更多相关文章

  1. PHP简单 对象(object) 与 数组(array) 的转换

    数组是PHP的灵魂,非常强大,但有时候面向对象编程也是挺方便的,数组 与 对象 之间切换也是常有的事: /** * 数组 转 对象 * * @param array $arr 数组 * @return ...

  2. php--------对象(object) 与 数组(array) 的转换

    php开发中常常用到数组,sql数据都是数组,数组和对象用的也是比较多的,常常相互转化,数组是PHP的灵魂,非常强大,面向对象编程也是挺方便的. /** * 数组 转 对象 * * @param ar ...

  3. Array of Objects

    You should be comfortable with the content in the modules up to and including the module "Array ...

  4. Javascript判断object还是list/array的类型(包含javascript的数据类型研究)

    前提:先研究javascript中的变量有几种,参考: http://www.w3school.com.cn/js/js_datatypes.asp http://glzaction.iteye.co ...

  5. JavaScript系统学习小结——Object类型、Array类型

    今天学习JavaSript中引用变量中的Object类型和Array类型: 1. Js中大多数引用类型值都是Object类型的实例,Object类型在应用程序中存储和传输数据时,是非常理想的选择: 创 ...

  6. 关于变量 Objects...objects 和Object[] objects的区别

    上一篇用到Objects...objects 和Object[] objects的遇到点小问题,于是我去做了个实验,关于这两个变量传参的问题 代码如下 package com.yck.test; pu ...

  7. 关于c.toArray might (incorrectly) not return Object[] (see 6260652)的问题解答

    最近学习jdk1.8源码时,发现ArrayList(Collection<? extends E> c)这个构造函数中,有句有意思的描述:c.toArray might (incorrec ...

  8. php--->把json传来的stdClass Object类型转array

    php把json传来的stdClass Object类型转array 1.Php中stdClass.object.array的概念 stdClass是PHP的一个基类,即一个空白的类,所有的类几乎都继 ...

  9. [ES6] Converting an array-like object into an Array with Array.from()

    Array.from() lets you convert an "iterable" object (AKA an array-like object) to an array. ...

随机推荐

  1. LoadRunner 测试java代码

    LR12 JDK 1.7,32位 环境变量配好 待测的java jar包及其依赖的jar包都整理好,放在jdk的lib目录下,也要把jar包放在脚本目录下! =====>新建Java Vuser ...

  2. http://localhost:8080请求用户名和密码。信息为:“XDB” 解决办法

    windows查看端口占用情况 cmd下 netstat -ano 查看端口和对应的服务 为2520 Oracle的服务 源博客: http://blog.163.com/jxguo_05/blog/ ...

  3. 解决一个项目里面加载两个同名不同版本的DLL的问题

    在config里面这样配置,可以加载不同版本的dll <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com ...

  4. p:nth-last-child(2)

    <!DOCTYPE html><html><head><style> p:nth-last-child(2){background:#ff0000;}& ...

  5. golang 面向对象

    深入理解GO语言的面向对象_Golang_脚本之家 https://www.jb51.net/article/94030.htm 深入理解GO语言的面向对象 更新时间:2016年10月04日 10:4 ...

  6. es字符串字段类型的私有属性 建立索引的分析器 用于查询的分析器 短语查询优化

    除了公共属性外,基于字符串的字段还有私有属性 term_vector  是否计算该字段的Lucene词向量term vector no  默认值 yes with_offsets with_posit ...

  7. document write & close

    在载入页面后,浏览器输出流自动关闭.在此之后,任何一个对当前页面进行操作的document.write()方法将打开—个新的输出流,它将清除当前页面内容. 必须确保调用document.close() ...

  8. app是什么意思?智能手机的第三方应用程序

    APP,在手机中的意思就是application的简称,也就是应用程序的意思,一般指手机软件,是安装在手机上的软件,完善原始系统的不足与个性化.APP是智能手机的第三方应用程序,app通常分为个人用户 ...

  9. 转载:阮一峰 理解RESTful架构

    转载 http://www.ruanyifeng.com/blog/2011/09/restful.html 越来越多的人开始意识到,网站即软件,而且是一种新型的软件. 这种"互联网软件&q ...

  10. python的分布式爬虫框架

    scrapy + celery: Scrapy原生不支持js渲染,需要单独下载[scrapy-splash](GitHub - scrapy-plugins/scrapy-splash: Scrapy ...