在Javascript数组的最大大小 [英] Maximum size of an Array in Javascript

查看:106
本文介绍了在Javascript数组的最大大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上下文:我建立一个小网站,上面写着一个RSS源和更新/检查在后台的饲料。我有一个阵列来存储数据来显示,而另一个存储的是已被证明的记录的ID。

Context: I'm building a little site that reads an rss feed, and updates/checks the feed in the background. I have one array to store data to display, and another which stores ID's of records that have been shown.

问:有多少项目可以在阵列中的Javascript装东西开始变得迟缓,呆滞或之前。我不是排数组,但我使用jQuery的inArray功能做一个比较。

Question: How many items can an array hold in Javascript before things start getting slow, or sluggish. I'm not sorting the array, but am using jQuery's inArray function to do a comparison.

该网站将保持运行状态,并更新其不可能的浏览器将重新启动/刷新经常。

The website will be left running, and updating and its unlikely that the browser will be restarted / refreshed that often.

如果我想从阵列清除一些记录,什么是限制之后,除去一些记录,比如100个项目的最好方式。

If I should think about clearing some records from the array, what is the best way to remove some records after a limit, like 100 items.

推荐答案

的最大长度,直到它变得行动迟缓是完全依赖你的目标机和实际code上,所以你需要测试上(那些)平台(S),看看有什么是可以接受的。

The maximum length until "it gets sluggish" is totally dependent on your target machine and your actual code, so you'll need to test on that (those) platform(s) to see what is acceptable.

然而,根据ECMA-262第5版规范的阵列的最大长度是由一个32位无符号整数,由于 ToUint32 的抽象操作的约束,所以尽可能长的阵列可以具有2 32 -1 = 4,294,967,295 = 4.29Hz十亿元素。

However, the maximum length of an array according to the ECMA-262 5th Edition specification is bound by an unsigned 32-bit integer due to the ToUint32 abstract operation, so the longest possible array could have 232-1 = 4,294,967,295 = 4.29 billion elements.

这篇关于在Javascript数组的最大大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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