First off, sorry for the vague title, I honestly don't know how to explain it without directly showing. I am new to JavaScript and have been learning arrow functions, however, I do not recognize this type of arrow function/syntax.
Currently, I am creating a website and am adding a session cookie using a passport with mongoose. The tutorial I am using has a very peculiar way of using the arrow function and am unable to find any information online pertaining to the syntax.
This is the code simplified
foo(bar)(()=>{
... Code Here ...
});
I understand the arrow function, but what I do not understand is how the parenthesis work in this situation and what really is going on?
|
V
foo(bar)(...)
I haven't been able to find anything online about this, and weird enough it runs without any errors when I run the function in the tutorial, however, if I do this with something like this,
function foo(){
console.log("In foo");
}
foo()(()=>{
console.log("In bar");
});
I will get an error saying
foo is not a function
The actual code being run will be down below if required
(This code is being run on a server, the req is the request data sent to a GET request, I am using passport JavaScript and mongoose here. The res variable is the response to the user, and yes this code works just fine no errors and it does what it needs to, I just don't understand how this syntax works).
req.authenticate("local")
((req, res)=>{
res.redirect("/");
});