Summary
Array callback methods currently pass multiple arguments to callbacks, but user-defined function calls enforce exact arity. This causes JS-incompatible failures for common callback forms like array.map(function (x) { ... }).
Reproduction
var array = [1, 4, 9, 16];
var mapped = array.map(function (x) { return x * 2; });
console.log(mapped);
Current behavior
Error: function 'anonymous' expects 1 arguments but got 3
Expected behavior
JavaScript-compatible argument handling for callbacks:
- extra callback arguments are ignored when the function declares fewer params
- missing callback arguments are bound as
undefined when the function declares more params
Notes
This affects callback-based methods added in issue #2 (forEach, map, filter, reduce, some, every, find, findIndex).
Summary
Array callback methods currently pass multiple arguments to callbacks, but user-defined function calls enforce exact arity. This causes JS-incompatible failures for common callback forms like
array.map(function (x) { ... }).Reproduction
Current behavior
Error: function 'anonymous' expects 1 arguments but got 3Expected behavior
JavaScript-compatible argument handling for callbacks:
undefinedwhen the function declares more paramsNotes
This affects callback-based methods added in issue #2 (
forEach,map,filter,reduce,some,every,find,findIndex).