SCOPE Flashcards

1
Q

What is a block ?

A

A block is the code found inside a set of curly braces {}. Blocks help us group one or more statements together and serve as an important structural marker for our code.

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

What are global variables ?

A

In global scope, variables are declared outside of blocks.
Because global variables are not bound inside a block, they can be accessed by any code in the program, including code in blocks.

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

What is the global namespace?

A

When you declare global variables, they go to the global namespace. The global namespace allows the variables to be accessible from anywhere in the program. These variables remain there until the program finishes which means our global namespace can fill up really quickly.

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

What is the global namespace?

A

When you declare global variables, they go to the global namespace. The global namespace allows the variables to be accessible from anywhere in the program. These variables remain there until the program finishes which means our global namespace can fill up really quickly.

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

What is the Scope pollution ?

A

Is when we have too many global variables that exist in the global namespace, or when we reuse variables across different scopes.

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

What is scope?

A

Scope refers to where variables can be accessed throughout the program, and is determined by where and how they are declared.

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

What is Global scope?

A

Global scope refers to the context within which variables are accessible to every part of the program.

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

What is block scope?

A

Block scope refers to the context within which variables are accessible only within the block they are defined.

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