This JavaScript example demonstrates how to write and call a function with rest parameters.
<!DOCTYPE html>
<html>
<head>
<title>XoaX.net's Javascript</title>
</head>
<body>
<script type="text/javascript" src="FunctionsRestParameters.js"></script>
</body>
</html>function Print(x, y, z, ...xAdditional) {
document.writeln("Inside Print()<br />");
document.writeln("--------------<br />");
document.writeln("x = " + x + "<br />");
document.writeln("y = " + y + "<br />");
document.writeln("z = " + z + "<br />");
document.writeln("<br />Additional:<br />");
for (var i = 0; i < xAdditional.length; i++) {
document.writeln(xAdditional[i] + "<br />");
}
document.writeln("<br />");
}
Print("Father", "Son", "Holy Ghost", "Michael", "Gabriel", "Raphael");
Print("XoaX.net", "Math", "C++", "JavaScript", 1, 2, 3, 4, 5, 6);
© 20072025 XoaX.net LLC. All rights reserved.