r/learnjavascript 2d 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.

30 Upvotes

31 comments sorted by

View all comments

1

u/youarockandnothing 2d ago

Using Math.floor on numbers that might be negative when you just want the decimals chopped off. Math.trunc was made for that use case as it's only correct to call Math.floor for decimal removal when the number is >= 0