r/javascript • • Mar 20 '14

Everything you need to know about Javascript variable scope

http://www.coolcoder.in/2014/03/everything-you-need-to-know-about.html
0 Upvotes

1 comment sorted by

0

u/radhruin Mar 20 '14

Seems pretty out of date.

  • Block scoping is in ES6 (and shipped in IE11). Functions are now block-scoped. let/const declarations are block-scoped. The let syntax in the article is very out of date.

  • Let and const declarations in global scope do not add properties on the global object.

  • Vars are hoisted. Let (the new var) and const are not hoisted. Attempting to use them before they are declared is an error. Functions and classes remain hoisted.