Chapter 3 Sample 6
For use in the Make Something Happen: Investigate let, var and const section.
Open the Developer Tools console and enter the name of a function to run it.
- letScopeDemo() - a variable declared using let in an inner block scopes out one in an outer block
- varScopeDemo() - a variable declared using var in an inner block replaces one in an outer block
- letDemo() - variables declared using let are not visible outside the block they are declared in
- varDemo() - variables declared using var can be used outside the block they are declared in
- globalDemo() - variables declared globally persist outside the block they are declared in
- strictGlobalDemo() - strict mode stops you declaring global variables
- constDemo() - variables declared using const cannot be changed