Hi everyone! After a long gap I was refreshing my JavaScript understanding and went through many blogs and videos. JavaScript is like a magic you w...
Some comments have been hidden by the post's author - find out more
For further actions, you may consider blocking this person and/or reporting abuse
I wonder about the point of copying code from "Javascript.info" and posting it here.
Wouldn't it be enough to post the link...
Thanks for suggesting, I will add it in reference
What happened in the 'application' section? 🤔
It's use cases where we can apply currying
Really? OK, I'll bite... please give examples of using currying to:
You can check this codepen example for manipulating dom codepen.io/emilsone/pen/jOwNgde
and in react where you attach a event handler onclick event to work as
const handleClick = (value)=>{
return (e)=>{
setValue({[value]: e.currentTarget.value }
}
}
You can also use it to create a function which will accept a event and the element as argument and will be used to add event listener or remove event listener
function on(type, element){
element.addListener(type, ()=>alert("clicked"));
return (a)=>element.removeListener(type,(a)=>alert("element removed"+a));
}
Currying isn't manipulating the DOM, nor is it triggering an event listener. Currying is merely a process to convert a function that takes multiple arguments into a sequence of functions that each takes a single argument.
Yes right currying is a process to convert a function with multiple arguments to multiple functions with single argument. Currying is used to manipulate the DOM and triggering an event listener. So this are "use-cases/scenarios" where you can use currying. That's the reason I have written them in "application" section and not in the "examples" section.
Thanks for reading my blog I will definitely share a blog to discuss currying use-cases/scenarios.
It seems we're fighting a language battle that is going round in circles
Very well, I got what you want to say but I have used currying in the following scenario and I feel mentioning them so that reader get an idea where they can apply it.