Is there a way to allow "unlimited" vars for a function in JavaScript?(有没有办法允许JavaScript中的函数使用“无限”的var?)
Example:(例:)
load(var1, var2, var3, var4, var5, etc...) load(var1)
Sure, just use the arguments object.(当然,只需使用arguments对象。)
arguments
function foo() { for (var i = 0; i < arguments.length; i++) { console.log(arguments[i]); } }
1.4m articles
1.4m replys
5 comments
57.0k users