Search code examples
javascriptnode.jssessionrequire

What is the meaning of second parentheses in front of "require()" function in JS?


I just saw this line of code:

var FileStore = require('session-file-store')(session);

I understand the code up to second parentheses but can't understand what is the second parentheses in general? Why it hasn't '' inside of it? Why the code uses it and how does it work?


Solution

  • It means that earlier in your file, you've required and defined session (most likely Express Session). This means that you're requiring session-file-store, executing the function with the required session, and assigning the return value of that function to FileStore.