A function with variable JavaScript parameters and variable javascript Parameters
Functions with variable JavaScript Parameters
Digress: I have been familiar with JavaScript For a long time, but I did not pay attention to it. I have seen JavaScript on many cool and dazzling web pages. Google's JavaScript Application has the biggest impact on me. I decided to learn it from the beginning, so I had the JavaScript & Ajax column. I plan to record this column as a study note, so every article note may be short, just one or two notes.
JavaScript allows a function to pass a variable number of parameters. Because arguments is a built-in object, it is an array of all parameters passed by a function. For example, you will understand. UI front-end framework can be carefully developed for 5 years!
<! DOCTYPE html PUBLIC "-// W3C // dtd html 4.01 Transitional // EN" "http://www.w3.org/TR/html4/loose.dtd">
Javascript function as parameter name
A simple example. Test environment: win7 + ie8 + chrome
<Script type = "text/javascript">
Function Add (x, y ){
Alert (x + y );
}
Function Sub (x, y ){
Alert (x-y );
}
Function CallFunc (Fun, x, y ){
If (Fun & (typeof Fun = "function ")){
If (x & y & (typeof x = "number") & (typeof y = "number ")){
Fun (x, y );
} Else {
Console. log (typeof x );
}
} Else {
}
}
CallFunc (Sub, 5, 3 );
</Script>
Setting multiple parameters in javascript Functions
OnClick = "biaoji ('<% = xzuo %>', '<% = yzuo %>', '<% = zzuo %> ');"
Replace it with this.