Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

Shouldn't the variables be declared using 'const' or 'let' instead of 'var' to comply with ES6 standards?

It seems that this lesson was created after the ES6 release, yet still exclusively declares variables using 'var'...

You have not linked to the lesson in question so I can't really comment on your question either way, but it should be noted that many tracks do contain courses that was recorded before Treehouse transitioned to ES6 but comes after the ES6 courses in the track.

My bad, first time posting a question and I didn't realize that the lesson wasn't linked by default. The lessons I am referring to are the jQuery Basics "Creating a Simple Lightbox" videos.

1 Answer

Daniel, I understand your confusion because Treehouse has done a terrible job explaining this, so allow me: ES6 (aka ES2015) was indeed "released" in June 2015, but even today in March 2017, there are plenty of very-much-used internet browsers -- desktop and mobile -- that do not support ES6 natively, so if you use let and const instead of var without any compiler (like Babel JS), you risk all of your site's JavaScript being completely broken for users. Check browser support for "let" on caniuse.com and click the "Show All" button to see all the browser versions (in particular iOS Safari up to 9.3, macOS Safari up to 9.1, Internet Explorer up to 10) for which let will be completely meaningless.

While we are close to being able to switch to ES6 syntax, it's pretty foolish to do so without "compiling" your JavaScript (basically a fancy way of saying using an automated process to convert ES6 syntax back into "old" JavaScript syntax) before you put it in a production environment. Let me know if you have any questions.