r/javascript • • May 28 '19

What are some JavaScript things beginners don't know?

333 Upvotes

383 comments sorted by

View all comments

141

u/inabahare May 28 '19

Using const and let

0

u/[deleted] May 28 '19

[deleted]

33

u/[deleted] May 28 '19

VSCode masterrace but WebStorm is right here. (Modern) JS shouldn't use var when not explicitly needed.

8

u/g0liadkin May 28 '19

I'm curious, would you say there is a situation when it's actually needed to use var?

10

u/Careerier May 28 '19

When you can't use a compiler like Babel and you have to support older browsers that don't know what `let` and `const` mean.

5

u/[deleted] May 28 '19

I imagine it can be more convinent sometimes to have a function-scoped variable. But even then we're probably talking about quickly hacking things together.

Out of the blue I cannot give you a production example of "a var variable would be better here"

8

u/turntopage294 May 28 '19

Out of the blue I cannot give you a production example of "a var variable would be better here"

I couldn't even give you a textbook example...

→ More replies (12)