Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript

Should we nolonger use var?

I just want to make sure i'm understanding the lesson correct.

From what I've gathered, var is considered an older practice and it is recommended not to use it in And today's age is recommended replaced with either let or const?

1 Answer

Jonathan Rhodes
Jonathan Rhodes
8,086 Points

let and const are a way to name variables in ES6, which will be the new standard in a few years. However, it is not currently supported by all browsers, so it is a risky move to code in unless you are using something to interpret it into ES5. var, the way to declare variables in ES5 will work in all browsers. As of right now, if you are just programming pure JavaScript, it's probably safer to use ES5.