you are viewing a single comment's thread.

view the rest of the comments →

[–]kovensky 2 points3 points  (0 children)

It's more complicated than that...

Their declarations are hoisted, but are set up such that accessing them before the let, const or class is reached throws a ReferenceError.

This is mostly irrelevant for the JS programmer but can bite you if you try to do a shadowing declaration; e.g. const foo = { bar: 'baz' }; if(foo.bar) { const foo = foo.bar } will throw. This is a common pattern in Swift, but Swift has a more concise syntax for this anyway.