这是preferable,A = []或=新的Array()?这是、preferable、Array

由网友(陌路)分享简介:在ActionScript 3中,这是preferable?In Actionscript 3, which is preferable?a = [1,2,3];或a = new Array(1,2,3);看来,调用数组构造数据作为单独的参数会更慢,而另一种方法将是某种形式的直接存储器复制。It appears...

在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.

阅读全文

相关推荐

最新文章