On 10 June 2012 03:52, Irakli Gozalishvili <[email protected]> wrote: > I just noticed strange behavior in spider monkey implementation of rest > arguments: > > (function(a, b, ...rest) {}).length // => 2 > > I think ignoring `rest` in length is pretty counter intuitive. For example I > have small utility function that > I use to dispatch depending on argument length. > > var sum = dispatcher([ > function() { return 0 }, > function(x) { return x }, > function(x, y) { return x + y }, > function(x, y, z) { return Array.prototype.slice.call(arguments, > 1).reduce(sum, x) } > ])
I don't think any library should ever rely on f.length. It is not a reliable source of information (f might use 'arguments' even when the length is officially 0), and I don't honestly see it being useful for anything but tertiary debugging purposes. /Andreas _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

