Tail function in javascript [duplicate]
问题 This question already has answers here : Variadic curried sum function (12 answers) Closed 4 years ago . I want to make a function which adds arguments. Invoking this function should be functionAdd(2)(3)(4)...(n); And the result 2+3+4...+n I'm trying this function myfunction(num){ var summ =+ num; if(num !== undefined){ return myfunction(summ); } }; But it doesn't works, an error of ovwerflow. And I don't understand where I should out from this function; 回答1: You can use the .valueOf to do