Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Global scope
- function sayHello () {
- // Local scope 1
- var greet = 'Hello!' // Scoped to local scope 1
- console.log('1: ', greet) // Accessible from local scope 1
- }
- function changeGreet () {
- // Local scope 2
- console.log('2: ', greet) // NOT Accessible from local scope 2
- }
- sayHello()
- changeGreet()
- // 1: Hello!
- // ReferenceError: greet is not defined
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement