问题描述
上下文:我正在构建一个读取 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.
推荐答案
它变得缓慢"之前的最大长度完全取决于您的目标机器和您的实际代码,因此您需要对其进行测试(那些)平台,看看什么是可以接受的.
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.
但是,由于 ToUint32 抽象操作,根据 ECMA-262 第 5 版规范,数组的最大长度受无符号 32 位整数的约束,因此可能的最长数组可能具有2-1 = 4,294,967,295 = 42.9 亿个元素.
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 2-1 = 4,294,967,295 = 4.29 billion elements.
这篇关于Javascript 中数组的最大大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!