Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
1×
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.

Autoplay

    Working with var, let, const, and block scopes

    javascriptJavaScript

    {} is overloaded to be either an object literal or a block scope. When an assignment is made to a variable inside of the {}, it then becomes a block scope. Otherwise it is treated as an object literal.

    var, let, and const respect block and function scopes differently. var is also hoisted and can be redeclare while that is not true for let and const. This lesson goes more in depth on scope and how each variable declaration treats it differently.