What does:
someFunction(args)(moreArgs);
Do in JavaScript?
I have a following working piece of code from the Passport.js documentation:
app.get('/login', function(req, res, next) {
passport.authenticate('local', function(err, user, info) {
if (err) { return next(err); }
if (!user) { return res.redirect('/login'); }
req.logIn(user, function(err) {
if (err) { return next(err); }
return res.redirect('/users/' + user.username);
});
})(req, res, next);
});
In this case passport.authenticate
is being called with args (the String local
and a Function) then afterwards (req, res, next)
exists.
In otherwords:
someFunction(args)(moreArgs);
This isn't an IIFE - there's no ()
around the function being ran. What is it?