是JavaScript数组实际上链表? [英] Are JavaScript arrays actually linked lists?

查看:492
本文介绍了是JavaScript数组实际上链表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的Javascript,并注意你不需要指定数组的大小和经常看到有人动态创建阵列在时间一个元素。这将是在其他语言中一个巨大的性能问题,因为你会不断地需要重新分配内存阵列,因为它增加的大小。

I'm new to Javascript, and notice that you don't need to specify an array's size and often see people dynamically creating arrays one element at time. This would be a huge performance problem in other languages as you would constantly need to reallocate memory for the array as it increases in size.

这难道不是在JavaScript中的一个问题?如果是这样,那么有没有一个列表结构可用?

Is this not a problem in JavaScript? If so, then is there a list structure available?

推荐答案

这很可能取决于你使用的JavaScript引擎。

It most likely depends on what JavaScript engine you use.

Internet Explorer使用稀疏数组和密集阵列的组合,使这项工作。一些更血​​淋淋的细节进行了说明:<一href=\"http://blogs.msdn.com/b/jscript/archive/2008/04/08/performance-optimization-of-arrays-part-ii.aspx\">http://blogs.msdn.com/b/jscript/archive/2008/04/08/performance-optimization-of-arrays-part-ii.aspx.

Internet Explorer uses a mix of sparse arrays and dense arrays to make that work. Some of the more gory details are explained here: http://blogs.msdn.com/b/jscript/archive/2008/04/08/performance-optimization-of-arrays-part-ii.aspx.

这篇关于是JavaScript数组实际上链表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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