这是preferable,A = []或=新的Array()? [英] Which is preferable, a = [] or a = new Array()?

查看:186
本文介绍了这是preferable,A = []或=新的Array()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ActionScript 3中,这是preferable?

In Actionscript 3, which is preferable?

a = [1,2,3];

a = new Array(1,2,3);

看来,调用数组构造数据作为单独的参数会更慢,而另一种方法将是某种形式的直接存储器复制。

It appears that calling the Array constructor with data as individual arguments would be slower and that the other method would be some sort of direct memory copy.

你知道哪个好,在大多数情况下使用,为什么?

Do you know which is better to use in most cases, and why?

推荐答案

我preFER方括号,因为它是一个更简洁和易于阅读的语法。

I prefer the square brackets because it's a more concise and easy-to-read syntax.

后者语法其实会慢一点,因为你可以通过做 =阵列功能(替代默认的数组构造){...}; - 至少在大多数的ECMAScript变种这个工​​程。因此,使用该形式将需要全球阵列函数先抬头。

The latter syntax will in fact be a bit slower, since you may replace the default array constructor by doing Array = function() { ... }; -- at least in most ECMAScript variants this works. So using that form will require the global Array function be looked up first.

这篇关于这是preferable,A = []或=新的Array()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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