Timo Timo - 1 year ago 75
Javascript Question

JavaScript variable number of arguments to function

Is there a way to allow "unlimited" vars for a function in JavaScript?


load(var1, var2, var3, var4, var5, etc...)

Answer Source

Sure, just use the arguments object.

function foo() {
  for (var i = 0; i < arguments.length; i++) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download