es6-const-let Flashcards

1
Q

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

A

the area surrounded by curly braces { }. Example is a function, for, while, or if statement code block.

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

What does block scope mean?

A

it means its scope is not global and is attached and exists only inside the current block

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

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

unlike let, const can’t be reassigned

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 array itself can be changed but the const variable can’t be changed; the value of the const variable can be changed but the value itself can’t be reassigned.

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

whether or not you want to reassign that variable or not and if it is in a block or not; use const unless you can’t

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