0

for example the connect function from 'react-redux' library, looks something like this:

connect(state)(SomeComponent)

I understand that connect function accepts a single parameter but what does the second parenthesis mean? It seems like another parameter but why does it have to be in a separate parenthesis? what are the use cases? What exactly is the term for this?

Lelouch
  • 910
  • 6
  • 19
  • 2
    That explains this but I needed to ask this question to know that the term for this is currying. Thanks! – Lelouch Feb 20 '19 at 06:44

1 Answers1

3

Presumably, connect is a function which returns a function, and then you can call that function with something else:

const connect = arg1 => arg2 => arg1 + arg2;
const result = connect(3)(4);
console.log(result);
Snow
  • 3,820
  • 3
  • 13
  • 39
  • Nice, thanks. How do I easily interpret nested functions like this? Like your given example of nested arrow functions, It strains my eyes trying to comprehend at one glance. What are some good use cases? – Lelouch Feb 20 '19 at 06:42