r/javascript • • May 28 '19

What are some JavaScript things beginners don't know?

333 Upvotes

383 comments sorted by

View all comments

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.

23

u/priceLbear May 28 '19

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?

5

u/kamenjan May 28 '19

I think he meant that your dev time is normal if you understand closures :) You know right away when to use arrow function and when not to, so you avoid frequent and pointless code refactoring on account of not understanding closures :)

11

u/[deleted] May 28 '19

I'd argue arrow functions have nothing to do with closures. Scope and closure are not synonymous.

6

u/[deleted] May 28 '19

If you are a React developer, you are leveraging closures on every single component render even if you're not realizing it.