1

How does this work:

 const invert = fn => (...args) => -fn(...args);

Specifically, what is happening with (...args). It behaves as if it is separating the arguments from the function after the first fat arrow, but I suspect there is a better, more specific, explanation. Thanks.

nevada
  • 19
  • 3
  • 1
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters – Bergi Feb 17 '18 at 21:50
  • Have you seen examples how this `invert` function is used? – Bergi Feb 17 '18 at 21:53
  • If you want to better understand ES6, this is a great resource https://babeljs.io/ – StudioTime Feb 17 '18 at 22:13
  • 1
    This is NOT an exact duplicate and quite a useful question for people trying to get to grips with arrow functions and spread operators. It helps to see the combination (and have it explained). – Katinka Hesselink Mar 31 '18 at 18:09

0 Answers0