标签:
在js中可以使用Object.prototype.toString.call()的来检测一个对象是否为一个数组
//检测数组 var a = [1, 2]; console.log(typeof a); //object console.log(Object.prototype.toString.call(a)); //[object Array] //检测字符串 var s = "you"; console.log(typeof s); //string console.log(Object.prototype.toString.call(s)); //[object String]
标签:
原文地址:http://www.cnblogs.com/scnuwangjie/p/5004711.html