es6-const-let Flashcards

1
Q

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

A

a code block is a block of code inside a set of curly braces. for example the if statement, for loop..

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

What does block scope mean?

A

the area within the curly braces that define a section indicating a block scope.

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 scoped, they only exist in the block they’re declared.

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

const variables are ready-only and the value can’t be reassigned. the values of let variables can be changed.
the scoping is the same though.

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

because the values of const variables cannot be re-assigned but you can change the value of its property or add new property.

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

depends on whether you want to have the same value for the variable or not. (use const unless you can’t then use let, use const for values that are not expected to change or like reference data types arrays and objects.)

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