This JavaScript example illustrates what happens when too many or too few arguments are passed into a function. When too many arguments are passed, the additional arguments may be accessed via the arguments object. When too few arguments are passed, the additional paramters are undefined.
<!DOCTYPE html> <html> <head> <title>XoaX.net's Javascript</title> <script type="text/javascript" src="TooManyOrTooFewArguments.js"></script> </head> <body onload="Initialize()"> </body> </html>
function F(x, y) { document.writeln(`x = ${x} : y = ${y}` +"<br />"); for (qArg in arguments) { document.writeln(qArg + " : " + arguments[qArg] + "<br />"); } document.writeln("<br />"); } function Initialize() { F(); F("XoaX.net"); F("XoaX", ".net"); F("XoaX", ".net", "says", "Hello!"); }
© 20072025 XoaX.net LLC. All rights reserved.