About the sum function one, what is the best way of doing that in ES5? I did like this, but I don't know if it would be the most appropriate way.
function sum(x) { if (arguments[1] == null) { return (function(y) { return 'With currying: ' + (x + y); }) } else { return 'Without currying: ' + (arguments[0] + arguments[1]); } }
Btw, nice article!
Thanks! I like that you found it useful.
Your solution is pretty straightforward and descriptive. I like it.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
About the sum function one, what is the best way of doing that in ES5? I did like this, but I don't know if it would be the most appropriate way.
function sum(x) {
if (arguments[1] == null) {
return (function(y) {
return 'With currying: ' + (x + y);
})
} else {
return 'Without currying: ' + (arguments[0] + arguments[1]);
}
}
Btw, nice article!
Thanks! I like that you found it useful.
Your solution is pretty straightforward and descriptive. I like it.