On Sun, Dec 23, 2012 at 1:26 PM, Wes Garland <w...@page.ca> wrote: > Arguments object is used here to fill the rest void, but also as an > argument to apply (after converting into a real array) when writing wrapper > functions; eg monkey patches, userspace profiling, etc. > > Is there an ES6 way to use apply on rest params? If not, arguments must > live on. >
There is something really nice. You can use the ... operator when calling a function. For example, if you're wrapping a function foo: _origFoo = foo; foo = function (a, b, ...rest) { // ... do something ... return _origFoo(a, b, ...rest); }; If you're wrapping a method it's not quite as nice, but: _origMethod = Bar.prototype.method; Bar.prototype.method = function (a, b, ...rest) { // ... do something ... return _origMethod.call(this, a, b, ...rest); }; -j
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss