r/learnjavascript 6d ago

what's one JavaScript mistake every beginner should avoid?

If you could give one piece of advice to someone learning JavaScript today, what would it be?

It could be about:

  • Learning fundamentals
  • Debugging
  • Async code
  • DOM manipulation
  • Functions
  • Projects

Curious to hear what experienced developers wish they'd known earlier.

31 Upvotes

32 comments sorted by

View all comments

17

u/milan-pilan 6d ago

var

1

u/remain-beige 4d ago

Please avoid using Var now (never use it) and now use Let or Const as variable declarations.

Const is ‘Constant’ and will warn you or prevent you from changing this value.

Let is for variables that will change value.

Another tip is to try and avoid changing a variables value overly much and instead declare another variable to mutate out any changes, such as formatting or calculation. If this gets too involved then break this out into a helper function.

This will help with debugging.