---
title: "jquery-isArray()判断是否为数组"
author: "小丑鱼0703"
date: "2015-01-29T18:17:29Z"
tags: []
categories: ["Web前端"]
slug: "jquery-isarray"
draft: false
lastmod: "2015-02-09T12:44:59Z"
id: 2181449
url: "https://wangjingyi.iteye.com/blog/2181449"
---

jQuery.isArray( obj ) 用来测试对象是否为一个数组。 \[code="jQuery"] var arr = \["1","2"]; alert($.isArray(arr));//true\[/code] \[code="html"]

测试我是否是数组：

\[/code] \[code="jQuery"] var arr = \["1","2"]; var str = $.isArray(arr); $("p").text($("p").text().concat(str));\[/code] 输出结果---\[color=blue]\[b]测试我是否是数组：true\[/b]\[/color] \[url]http://zhangyaochun.iteye.com/blog/1202853\[/url] \[code="js"] function isArray(source) { return Object.prototype.toString.call(source) === "\[object Array]"; } alert(isArray(\[1, 2]));//true alert(isArray({name: 'wjy'}));//false //Object.prototype.toString.call({name: 'wjy'});返回值：\[object Object] \[/code]