var arr = new Array();
typeof arr; 不能判断Array,获得的是object
Object.prototype.toString.call(arr); [object Array]
本文介绍了一种使用JavaScript来准确判断变量是否为数组的方法。通过对比typeof操作符与Object.prototype.toString.call()方法,揭示了typeof在处理数组类型时的局限性,并提供了一个可靠的方式来区分数组和其他对象。
var arr = new Array();
typeof arr; 不能判断Array,获得的是object
Object.prototype.toString.call(arr); [object Array]
转载于:https://www.cnblogs.com/-gap/archive/2012/08/22/2650302.html

被折叠的 条评论
为什么被折叠?