在javascript中将数组作为函数的参数传递 [英] pass an array as a function's arguments in javascript

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

问题描述

你好,

我正在寻找一种将数组作为函数参数传递的方法.

有人有任何想法吗?

我想这样做,

我只是将元素存储在服务器端的数组中,而我试图将该数组传递给Java脚本中的函数,但是我不能,


请帮助

Hello,

I''m looking for a way to pass an array as a function''s arguments.

Does anybody have any ideas to do this?

I want to do that,

I just stored elements in array at server side and i am trying to pass that array to function in java script, but i cant,


Please help

推荐答案

这两种不同的语言中的每一种(请参阅我对问题的评论)都允许传递任何类型的参数,包括数组. >
更确切地说,在C#中,这是数组类型,它是引用类型,因此请按值传递它.

对于JavaScript,您可以传递任何对象并以任何方式对其进行处理,但是您应该理解,在这种语言中,没有类型(语言类型系统是松散类型"和基于原型",不是此字词在通常意义上的类型).您只需传递任何对象并在函数主体中对其结构进行一些假设就对其进行处理.

简而言之,您不必寻找任何方式.只需传递一个参数即可.

—SA
Each of these two different languages (please see my comment to the question) allows passing of an argument of any type, including the array.

More exactly, in C# this is the array type, which is a reference type, so pass it by value.

As to JavaScript, you can pass any object and process it in any way, but you should understand that in this language, there are no types (the language type system is "loose-type" and "prototype-based", which is not the type in the usual sense of this word). You just pass any object and process it inside the function body in some assumptions on its structure.

In a few words, you don''t have to find any ways. Just pass a parameter, that''s it.

—SA


检查这些链接

JavaScript数组参数 [如何将数组作为参数传递? [
Check these links

JavaScript Array Arguments[^]

How to pass an array as a parameter?[^]


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

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