es6-const-let Flashcards

1
Q

What is a code block? What are some examples of a code block?

A

A code block is anything between curly braces. Functions, conditional blocks, or loops have their own code blocks.

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

What does block scope mean?

A

Block scope means that a variable is declared and lives between the curly braces but does not live outside those set of curly braces.

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

What is the scope of a variable declared with const or let?

A

Block scope

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

What is the difference between let and const?

A

Let is a variable declaration keyword for mutable variables and const is a variable declaration keyword for immutable variables.

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

Why is it possible to .push() a new value into a const variable that points to an Array?

A

The contents of reference data types can change as long as there is no reassignment.

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

How should you decide on which type of declaration to use?

A

Use const to declare variables unless the value has to be reassigned, then use let

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