A few weeks ago I spent some time learning about closure and I understand the concept. How exactly does it speed up dev time though? Do you use it often? If yes, could you describe some use cases I obviously fail to see?
It doesn't really. Maybe because everything is private and you don't have to use this everywhere or program as defensively?
In my experience, if you're someone building off or extending a library, it will slow you down. It sucks to extend a library or framework that uses closures because you don't have access to internals. Also closures are slower and more resource intensive (execution wise) if there's many instances.
Great for singletons or for your own libraries that no one has to extend though
152
u/[deleted] May 28 '19
Closure is a concept I see lots of beginners struggle with. You can massively speed up dev time once you grasp how it works in JS.