es6-const-let Flashcards

1
Q

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

A

Code within two { }… for, while, if, etc

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

What does block scope mean?

A

Variables only work within a specific code 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

Let keywords are block-scoped. Const is read only block-scope variable.

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 can change, while const remains fixed. Const also needs to be initialized.

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

Variable only holds a pointer to a memory… You can make modifications.

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

Depending on if you want to change a value or a variable later or not. Always use const, and if you can’t, use let. Use let in a loop…. in an if statement, you can use let. Otherwise, always use const.

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