JavaScript数组参数列表 [英] javascript array parameter list

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

问题描述

可能重复:结果
  <一href=\"http://stackoverflow.com/questions/676721/calling-dynamic-function-with-dynamic-parameters-in-javascript\">Calling在JavaScript中

我已经重新presenting我需要传递给函数调用的参数数组。如何动态构造此函数调用?

I have an array representing the parameters I need to pass to a function call. How can I construct this function call dynamically?

例如

function constructRequest(params) {
   //params is an array of params to be sent to myFunction()

   myFunction(params[0],params[1], ... , params[i]);

   //myFunction() needs to have the array deconstructed and is ready 
   // to accept optional params
}

感谢

推荐答案

使用参数

function A()
{
    alert( arguments[0] ); // 1
    alert( arguments[1] ); // 2
    alert( arguments[2] ); // 3
}

A(1, 2, 3);

<一个href=\"https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Functions#Using_the_arguments_object\"相对=nofollow>更多关于MDC信息(Mozilla的开发中心)。

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

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