什么是除外。长度属性的JavaScript数组和对象之间的区别? [英] What's the difference between JavaScript Array and Object except .length property?

查看:125
本文介绍了什么是除外。长度属性的JavaScript数组和对象之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我想到,JS数组只是一个哈希地图,只接受整数值作为重点。而物业。长度只返回最大索引+ 1。

As I think, JS array is just a hash-map which accepts only integral value as a key. And the .length property just return largest index + 1.

这是正确的?是否有任何其他区别?

Is this right? Is there any other differences?

推荐答案

的区别是:

Object.prototype.toString.call([]); // [object Array]
Object.prototype.toString.call({}); // [object Object]

编辑:

另外,看看从ECMAScript中规格本节,因为它precisely解释数组是什么: http://bclary.com/2004/11/07/#a-15.4

Also, have a look at this section from ECMAScript specifications as it precisely explains what an Array is: http://bclary.com/2004/11/07/#a-15.4

这篇关于什么是除外。长度属性的JavaScript数组和对象之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆