Oh man, I finally found a convincing example to curry functions in javascript. I'm not sure why you call it closure though (I've never been able to wrap my head around the word - so many different explanations). But this is definitely function currying.
Ryan is an engineer in the Sacramento Area with a focus in Python, Ruby, and Rust. Bash/Python Exercism mentor. Coding, physics, calculus, music, woodworking. Looking for work!
As far as I know, a closure is anytime you wrap a function in an outer scope and return it, such that that function has access to the outer scope long after that outer scope has ended.
After doing some reading, it looks like currying is when you break a multi-parameter function into a series of nested functions and you end up only passing in one thing at a time? In which case, it would seem like currying is just one specific example in the broader case of closures. Let me know if that sounds right or if I'm missing something.
If you haven't already, you might like to take a look at an article I wrote a few weeks ago that goes more into detail about closures. The code examples are in Python, but I think the point still comes across.
Thanks again!
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.
Oh man, I finally found a convincing example to curry functions in javascript. I'm not sure why you call it closure though (I've never been able to wrap my head around the word - so many different explanations). But this is definitely function currying.
Thanks for this amazing example :)
Hey, glad you liked it, thanks for the feedback!
As far as I know, a closure is anytime you wrap a function in an outer scope and return it, such that that function has access to the outer scope long after that outer scope has ended.
After doing some reading, it looks like currying is when you break a multi-parameter function into a series of nested functions and you end up only passing in one thing at a time? In which case, it would seem like currying is just one specific example in the broader case of closures. Let me know if that sounds right or if I'm missing something.
If you haven't already, you might like to take a look at an article I wrote a few weeks ago that goes more into detail about closures. The code examples are in Python, but I think the point still comes across.
Thanks again!