是什么凝聚阵列和阵列面值之间的区别? [英] What is the difference between condensed arrays and literal arrays?

查看:167
本文介绍了是什么凝聚阵列和阵列面值之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所说:是什么凝聚阵列和阵列面值之间的差额

As the title says: What is the difference between condensed arrays and literal arrays?

new Array("John", "Bob", "Sue"); // condensed array

["John", "Bob", "Sue"]; // literal array

有没有一些事情我可以用一个,我不能与其他做呢?或者是它被保存在内存的方式?

Are there things I can do with one that I can't do with the other? Or is it the way it is kept in the memory?

推荐答案

后,没有在生成的目标没有什么区别,它们是相同的。

No, there is no difference in the produced object, they are the same.

首先是为了满足那些使用一个经典的环境中,你必须实例化一个新Array对象编程的一种尝试。

The first is an attempt to satisfy programmers that are use to a "classical" environment where you have to instantiate a "new" Array object.

应当注意的是,阵列中的JavaScript不是存储器的顺序分配,但具有可枚举属性名称和一些额外的(有用)的方法的对象

It should be noted that Arrays in javascript are not a sequential allocation of memory, but objects with enumerable property names and a few extra (useful) methods.

在大多数(如果不是全部)的情况下相当无用的和不必要的。

Because of this creating an array of a set length is fairly useless and unnecessary in most (if not all) cases.

var array = new Array(10);

在功能上同样是手动设置您的数组的长度

is functionally the same is manually setting the length of your array

var array = [];
array.length = 10;

这篇关于是什么凝聚阵列和阵列面值之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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