Ad
  • Default User Avatar

    Hi, I'm a bit unclear on the exact specification. What should it do if the number of arguments supplied when calling the returned function is higher than the number of "defaultless" arguments, but lower than the total number of arguments? Should it start filling them in from the first argument, or first fill in the defaultless ones and somehow proceed with the others?

    Example: if I have a function add4(a, b, c, d) { return a + b + c + d; } and add4WithDefaults = defaultArguments(add4, {a:1, c:3}); , then what should add4WithDefaults(2, 4, 5) return? Should in this case make it a = 1, b = 2, c = 3, d = 4 and disregard the third argument? Or should it be a = 2, b = 4, c = 3 and d = ??? (resulting in NaN)? Neither seems right.