January 2020
Intermediate to advanced
470 pages
11h 13m
English
In Chapter 1, Becoming Functional - Several Questions, and Chapter 2, Thinking Functionally - A First Example, we saw some uses of the spread (...) operator. However, the most practical usage we'll be making of it has to do with working with arguments; we'll see some cases of this in Chapter 6, Producing Functions – Higher-Order Functions. Let's review our once() function:
const once = func => { let done = false; return (...args) => { if (!done) { done = true; func(...args); } };};
Why are we writing return (...args) => and then afterwards func(...args)? The answer has to do with the more modern way of handling a variable number (possibly zero) of arguments. How did you manage such kinds of code in older versions of ...
Read now
Unlock full access