javascript中的数组 [英] Array in javascript

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

问题描述

嗨。


是否有可能在javascript中操作阵列而不知道它有多少mamy

元素?

我想要做的是将一个数组发送到一个脚本,这个脚本应该

添加该数组中的所有值


你能告诉我一点吗例子怎么做?


谢谢。

Leszek

Hi.

Is it possible in javascript to operate on an array without knowing how mamy
elements it has?
What i want to do is sending an array to a script, and this script should
add all values from that array

Could you show me a little example how to do this?

Thanks.
Leszek

推荐答案

Leszek写道:
Leszek wrote:
在javascript中是否可以在不知道如何使用mamy元素的情况下对数组进行操作?


当然。这就是例如Array对象的`length''属性用于。

我想要做的是将一个数组发送到一个脚本,这个
脚本应该添加该数组的所有值

你能告诉我一个如何做到这一点的例子吗?
Is it possible in javascript to operate on an array without knowing how
mamy elements it has?
Of course. This is what the e.g. `length'' property of Array objects is for.
What i want to do is sending an array to a script, and this
script should add all values from that array

Could you show me a little example how to do this?




取决于你的意思是将数组发送到脚本 (哪个数组,

哪个脚本,客户端或服务器端,从何处发送?)和

脚本应该添加该数组的所有值 ; (从哪里加到

哪个?)

PointedEars



Depends on what you mean by "sending an array to a script" (which array,
which script, client-side or server-side, send from where to where?) and by
"script should add all values from that array" (add from where exactly to
which?)
PointedEars




Leszek写道:

Leszek wrote:
嗨。

是否有可能在javascript中操作数组而不知道它有多少mamy
元素?


JavaScript数组是Dynamic Sparse Jagged Array。这可能是一段时间的形容词太多了b / b:但是第一个意味着可以在没有ReDim / resize()的情况下向数组中添加新的元数据。


var myArray = new Array(); // 0元素

myArray [0] = 0;

....

....

myArray [1000] = 1000;


关于其他形容词(以及整个JavaScript数组)你可以

阅读:

< http://www.geocities.com/schools_ring/ArrayAndHash.html>

我想要做的是将一个数组发送到一个脚本,这个脚本应该添加那个数组中的所有值
你能告诉我一个如何做到这一点的例子吗?
Hi.

Is it possible in javascript to operate on an array without knowing how mamy
elements it has?
JavaScript array is Dynamic Sparse Jagged Array. That can be too much
of adjectives for one time :-) but the first one means that can add new
elements to array without ReDim / resize() it.

var myArray = new Array(); // 0 elements
myArray[0] = 0;
....
....
myArray[1000] = 1000;

About other adjectives (and about JavaScript arrays at whole) you can
read at:
<http://www.geocities.com/schools_ring/ArrayAndHash.html>
What i want to do is sending an array to a script, and this script should
add all values from that array
Could you show me a little example how to do this?




正如所指出的那样取决于如何以及以何种形式你是获得数组的原始数据吗?



As it was pointed out it depends on how and in what form are you
getting the original data for your array.


Leszek
是否有可能javascript在阵列上操作而不知道它有多少mamy
元素?
Is it possible in javascript to operate on an array without knowing how mamy
elements it has?




我不认为,没有''map'这样的功能'或''申请''。然而,他们

并不难实现,因为你总是知道一个

数组的大小:array.length;


-

我的桌面价值一百万美元。在上面放一个图标。
http://www.milliondollarscreenshot.com/


这篇关于javascript中的数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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