0

This SO answer elegantly explains how a "function with multiple parentheses" like the one below works:

myFunction(3)(4)

But I'd like to google it and read more about it. Does this way of constructing a function have a name?

Fellow Stranger
  • 32,129
  • 35
  • 168
  • 232
  • 5
    Looks like a [curried function](https://stackoverflow.com/questions/36314/what-is-currying). – CRice Dec 19 '17 at 17:33
  • 1
    The link you provide shows an example of IIFE (https://developer.mozilla.org/fr/docs/Glossaire/IIFE) – RaphaMex Dec 19 '17 at 17:36

1 Answers1

2

There is no such thing as a "function with multiple parentheses".

However, you can write a function that returns a function. So you pass arguments to your function with 1st parentheses, get a function in return, and pass arguments to the returned function with 2nd parentheses.

This is mainly used for IIFE when combined with closure. This technic is also called currying, as suggested by @CRice.

RaphaMex
  • 2,781
  • 1
  • 14
  • 30