1. What is the scope of variable GLOBAL_DATA in the example below:
< script >
let GLOBAL_DATA = { value : 1 } ;
</ script >
Pretend in the console, that we type:
console.log(GLOBAL_DATA);
2. What is the scope of variable x in the examples below:
let x = 1 ;
{
let x = 2 ;
}
console . log ( x ) ;
var x = 1 ;
{
var x = 2 ;
}
console . log ( x ) ;
3. What is the scope of variable x in the examples below:
function outerFn ( ) {
let x = 1 ;
function log ( ) {
console . log ( x ) ;
} ;
function run ( fn ) {
let x = 100 ;
fn ( ) ;
}
run ( log ) ;
} ;
outerFn ( ) ;
4. What do we call this method of scoping:
let x0 = 0 ;
function fn1 ( ) {
let x1 = 1 ;
fn2 ( ) ;
function fn2 ( ) {
let x2 = 2 ;
fn3 ( ) ;
function fn3 ( ) {
let x3 = 3 ;
console . log ( x0 + " " + x1 + " " + x2 + " " + x3 ) ;
} ;
} ;
} ;
fn1 ( ) ;
5. What is the difference between global scope and other scope types and when do we use the global scope?
6. What is the difference between let and var defining a variable?
7. What is the difference between strict mode and sloppy mode?