Presumably we are not unfamiliar with the parameters of the transfer, this article for you to introduce the parameters of JS transfer, the need for friends can refer to the next
Normally, passing parameters are probably all written as follows:
The code is as follows:
var numparameter = 123;
function Sendparameter ()
{
GetParameter (Numparameter);
}
function GetParameter (sendnum)
{
alert (sendnum);
}
A very simple a method calls the B method and passes the argument.
However, if the parameters of the B method are not fixed, they may require different parameters depending on the situation, and can be written as follows:
The code is as follows:
var txtParameter1 = "123";
var txtParameter2 = "234";
var txtParameter3 = "345";
var txtsendparameter = "";
var flag = 0;
function SendParameter1 ()
{
flag = 1;
Txtsendparameter = TxtParameter1 + ";" + txtParameter2;
GetParameter ();
}
function SendParameter2 ()
{
flag = 2;
Txtsendparameter = TxtParameter2 + ";" + TxtParameter3;
GetParameter ();
}
function GetParameter ()
{
if (1==flag)
{
Goto Functionc (Txtsendparameter)
}
else if (2==flag)
{
Goto Functiond (Txtsendparameter)
}
Else
{
Return
}
}
So can you not use global variables to pass values:
Copy code code as follows:
var txtParameter1 = "123";
var txtParameter2 = "234";
var txtParameter3 = "345";
function SendParameter1 ()
{
var txtsendparameter = "1" + TxtParameter1 + ";" + txtParameter2;
GetParameter (Txtsendparameter);
}
function SendParameter2 ()
{
var txtsendparameter = "2" + TxtParameter2 + ";" + TxtParameter3;
GetParameter (Txtsendparameter);
}
function GetParameter ()
{
Switch (Arguments[0])
{
Case "1":
Goto Functionc (arguments);
Break
Case "2":
Goto Functiond (arguments);
Break
Default
Goto Functione (arguments);
}
}
Relatively speaking, arguments is a very flexible object, although not array, but can use the same as the array of subscript value, although a bit rare, but still very good.
The code is as follows:
<pre code_snippet_id= "179244" snippet_file_name= "blog_20140207_4_1482200" name= "code" class= "JavaScript" > <pre code_snippet_id= "179244" snippet_file_name= "blog_20140207_4_1482200" ></pre>
<pre></pre>
<pre></pre>
<pre></pre>
<pre></pre>
<pre></pre>
</pre>