Not sure if I understood what you want, but
function sum(n) {
var v = function(x) {
return sum(n + x);
};
v.valueOf = v.toString = function() {
return n;
};
return v;
}
console.log(+sum(1)(2)(3)(4));
More Related Contents:
- What is ‘Currying’?
- JavaScript curry: what are the practical applications?
- How can I make var a = add(2)(3); //5 work?
- How to correctly curry a function in JavaScript?
- How to curry a function across an unknown number of parameters
- What is wrong with this function
- Making a quiz in HTML and Javascript [closed]
- Escaping HTML strings with jQuery
- Firestore Update single item in an array field
- jQuery’s .click – pass parameters to user function
- Cross-Browser Method to Determine Vertical Scroll Percentage in Javascript
- Using “Object.create” instead of “new”
- What is the difference between Bower and npm?
- Inspect extension’s chrome.storage in devtools
- How to break/exit from a each() function in JQuery? [duplicate]
- What does @@ (“at at”) mean in ES6 JavaScript?
- How do I localize the jQuery UI Datepicker?
- How do image preloaders work?
- In React and Next.js constructor, I am getting “Reference Error: localstorage is not defined”
- Regarding JavaScript new Date() and Date.parse()
- how to implement regions/code collapse in javascript
- How to embed a PDF in HTML page?
- console.log(myFunction()) returns undefined
- How to remove jQuery Mobile styling?
- How to get access to webpack-dev-server from devices in local network?
- How can I do an asc and desc sort using underscore.js?
- Obtaining “this” tab ID from content script in Chrome extension?
- Resolving spring:messages in javascript for i18n internationalization
- how to find out if XMLHttpRequest.send() worked
- executeScript is undefined or not a function in a ManifestV3 extension