var foo = function (s,n,o,a,f) { //use forEach to loop over the arguments array-like object [].forEach.call(arguments,function(e){ console.log(e) }); }; // again, this works because arguments is an object and has .length property foo('s',1,{},[],function(){});