How do I implement a adder function in javascript which can be invoked like
adder(1,2)(5,6,2)(4,9,10,11)(6,7).....()
The function should accept any number of arguments and add them all together. The function can be invoked in following ways.
adder(2,3,5) // prints 10
adder(2,3)(5) // prints 10
adder(2)(3)(5) //prints 10
What is best possible way to implement this function using closures?