I was not comfortable with this syntax the first time I learnt this and hence even though it makes sense now, I still write it in two different lines so it would be easier for everyone reading.
constintermediateFn=something();// something returns a functionconstresult=intermediateFn();// calling the fn returned from something
In this case, assuming the function something returns a function, the first set of parenthesis will execute the something function, just like normal; the second set of parentheses will then execute the function that something returned.
I read something like this in a random code: something ()(). What do two parenthesis represent?
I was not comfortable with this syntax the first time I learnt this and hence even though it makes sense now, I still write it in two different lines so it would be easier for everyone reading.
If you are familiar with React, this syntax is what is used with Redux connect or Apollo's graphql.
In this case, assuming the function
somethingreturns a function, the first set of parenthesis will execute thesomethingfunction, just like normal; the second set of parentheses will then execute the function thatsomethingreturned.I really appreciate your response. Thank you for making these hardcore concepts easy to digest