This JavaScript example demonstrates how to write and call a function with variable arguments.
<!DOCTYPE html> <html> <head> <title>XoaX.net's Javascript</title> </head> <body> <script type="text/javascript" src="FunctionsVariableArguments.js"></script> </body> </html>
function Print() { document.writeln("Inside Print()<br />"); document.writeln("--------------<br />"); for (var i = 0; i < arguments.length; i++) { document.writeln(arguments[i] + "<br />"); } document.writeln("<br />"); } // Call the function with string arguments Print("Matthew", "Mark", "Luke", "John"); // Call the function with three arguments of various types. Print(3.5, 83, "XoaX.net");
© 20072025 XoaX.net LLC. All rights reserved.