SPA Flashcards

1
Q

Describe hoisting

A

A process whereby a variable declaration is “hoisted” to the top of a function and given the undefined value, until it is defined.

function person(){
  console.log(succeed); //output is undefined
  var succeed = 'I am defined';
  console.log(succeed); //output ' I am defined '
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

why is hoisting important

A

Hoisting is important because it gives visibility to a variable declaration throughout the function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

describe the execution context

A

The execution context is a state in which the function is being executed. All the variables and functions within a function are considered to be in the execution context

function person(){
  var name = 'Succeed';
   function second_function(){
     console.log(name);
   } 
}
//all variables and functions are within the execution context
// second_function has access to name because its within the person execution context
How well did you know this?
1
Not at all
2
3
4
5
Perfectly