es6-const-let Flashcards

1
Q
  1. What is a code block? What are some examples of a code block?
A

blocks are denoted by curly braces {}

functions, if statements, loops

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

What does block scope mean?

A

Inside the 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 withconstorlet?

A

Block scoped.

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

What is the difference betweenletandconst?

A

The const keyword creates block-scoped variables whose values can’t be reassigned.
The variables declared by the let keyword are mutable. It means that you can change their values anytime you want

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 aconstvariable that points to anArray?

A

actual value to which the const variable reference is not immutable.
We can change the array element

6

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

By figuring out if the value will need to be reassigned.
Favor const over let.
Let lets you know the variable will be reassigned.

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