The concept of closure is important when it comes to understanding how languages such as Javascript work - and how scopes, lifetimes and references...
For further actions, you may consider blocking this person and/or reporting abuse
Something to add: you can create new scopes anywhere you want, provided the compiler doesn't think you're trying to initialize an object. A function body isn't necessary.
Though, doing that looks ugly and probably isn't ideal. An example of a valid use case is switch statements, it allows you to isolate each case into its own local scope.
You are right, this is also something interesting about scopes. Thanks for pointing out!
In ReactJS, my first encounter with closures was in form of arrow functions:
I was so confused at first, then i was like: wait a sec, it is just something that returns something that in return returns something. Aha! Know what i am sayin'?
Edit: For the sake of correctness, I think this statement is somewhat wrong:
Currying is the broader term, and closure is just a practice of it in programming.
Thanks for pointing out! I've updated the post 😆
Your posts are getting better and better every time, really good explanation and examples
Tnx, I'm really glad to help 😊
nice post, congratz
Thanks 😊
Hello wrongbyte,
Thank you for your article.
I read something about closures years ago.
Reading your article helped me refresh some of my knowledge about closures.
I'm glad I could help! 😄
Nice post. Closures are one of the most useful concepts to understand in languages that have them.
For sure! And they are very interesting