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 group of code within an opening and closing curly brace, an example would be functions, loops, ect.

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

What does block scope mean?

A

The code inside of a block that is not visible outside of the block. The code is only available inside of 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 with const or let?

A

They should both be block scopes.

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: works similar to be var (value can be changed)
Const: cannot be reassigned (value cannot change)

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

Const defines reference, reference cannot be reassigned but value can be changed

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

If the value needs to change: let, if the value doesnt need to change: const

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