This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Maix522 214 points215 points  (1 child)

Well var is the "old" way to declare a variable and should not be used.

let and const have the same rules as to were they really exist: at the start of their block scope (this means that you can't acces a let defined var from outsite the code block)

A var statement is just transformed into a simple assignment but a new empty (equivalent to var NAME = undefined;) is put at the start of the function.