General Questions Flashcards

(4 cards)

1
Q

What are the two main phases of JavaScript execution?

A

1- Compilation
2- Execution

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

What is Lexical Scoping?

A

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.

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

What is the difference between a function declaration and a function expression?

A

Function declarations are:
- Hoisted
- Named
- Creates a binding in the current scope.

Function expressions are:
- Anonymous or named
- Not hoisted
- Often used as callbacks

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

What is a Module in JavaScript?

A

A self-contained unit of code that encapsulates related functions, classes, or variables.

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