实际上(引自《JavaScript “Associative Arrays” Considered Harmful》):
There is no way to specify string keys in an array constructor. //在数组构造函数中无法定义字符串键值JavaScript arrays (which are meant to be numeric) are often used to hold key/value pairs. This is bad practice. Object should be used instead.
//大意:数组只支持数字的,键值对应使用于对象上。
扩展阅读:
《Javascript Array Fun》2、可使用 “The Miller Device” 方法来判断是否是数组
代码如下:扩展阅读:
《The Miller Device》 《isArray: Why is it so bloody hard to get right?》新闻热点
疑难解答
图片精选