Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lolit6's avatar

Using var, let, const? Is coursera outdated?

Hello,

I am very new to programming, and I am enrolled in a coursera course for front-end dev. The first lesson was on how to declare a variable using "var". But other YouTube tutorials that I took before enrolling the course (Traversy Media) taught me to never use var, and only stick to let and const?

Is there something I need to learn or unlearn here?

0 likes
2 replies
nexxai's avatar

In a perfect world, you would only use let or const but you live in a world where you will eventually see older code where that wasn't standard practice.

Long story short: for new code, use let or const but understand that you will almost certainly see var in your travels as a developer.

1 like
jlrdw's avatar

Using var is fine. Just be careful to not re-declare it at a wrong place. I'd get in the habit of using javascript a minimum amount. Use for lookup tables, modals, etc.

Please or to participate in this conversation.