General Questions Flashcards
(4 cards)
What are the two main phases of JavaScript execution?
1- Compilation
2- Execution
What is Lexical Scoping?
Lexical scoping means that the scope of a variable is determined by where it is defined (written in the code), not where it is called or executed.
Think of it this way: when the JavaScript engine processes your code, it knows exactly which variables are accessible in which parts of your program just by looking at the structure of the code, even before it runs.
What is the difference between a function declaration and a function expression?
Function declarations are:
- Hoisted
- Named
- Creates a binding in the current scope.
Function expressions are:
- Anonymous or named
- Not hoisted
- Often used as callbacks
What is a Module in JavaScript?
A self-contained unit of code that encapsulates related functions, classes, or variables.