DEV Community

Discussion on: Closures - JavaScript Concepts

Collapse
 
boywithsilverwings profile image
Agney Menon

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.

const intermediateFn = something(); // something returns a function
const result = intermediateFn();  // calling the fn returned from something

If you are familiar with React, this syntax is what is used with Redux connect or Apollo's graphql.