Question on let/var and const/function


#1

This is more of a general query rather than about specific code. I am working my way through the Return II tutorial and have been using var and function. In these forums I see a lot of people using let instead of var, and const instead of function. Why is this? It seems that let and const might be a new standard, but if so, why are my tutorials still using the old ones?


#2

let and const where introduced in es6 (released in 2015), they offer a block scope rather then a function scope (var)

there are two Javascript courses:

https://www.codecademy.com/learn/learn-javascript

https://www.codecademy.com/learn/introduction-to-javascript

the last one teaches es6


#3

Ok thanks for your reply. Should I be working through the introduction to JavaScript course instead then? Or do both?


#4

I think you should learn es6, if the browser support isn’t enough for your website you can always transpile the code into es5 using webpack.


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.