Off topic: I came into contact with JavaScript a long time ago, but I didn’t pay attention to it. I saw many cool and dazzling web pages, including JavaScript. Google’s application in JavaScript has the greatest impact on me. I'm determined to learn it from scratch, so I have the JavaScript & Ajax section. I plan to record this column as study notes, so each article note may be very short, just annotated in one or two sentences.
JavaScript allows a function to pass variable parameters because there is a built-in object arguments, which is an array of all parameters passed by a function. Take an example and you will understand.
The code copy is as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Function with variable number of JavaScript parameters</title>
<mce:script language="javascript" type="text/javascript"><!--
function testparams()
{
var params = "";
for (var i=0; i<arguments.length; i++) {
params = params + " " + arguments[i];
}
alert(params);
}
testparams("abc", 123);
testparams(123, "456", 789);
testparams();
// --></mce:script>
</head>
<body>
</body>
</html>