Var vs Let vs Const and the temporal dead zone

Learn the new ways of declaring variables introduced in ES6.

With the introduction of let and const in ES6, we can now better define our variables depending on our needs. During our JavaScript primer we looked at the basic differences between these 3 keywords, now we will go into more detail.

 

Var #

Variables declared with the var keyword are function scoped, which means that if we declare them inside a for loop (which is a block scope), they will be available even outside of it.

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy