ES6 const and let Flashcards

1
Q

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

A

code that runs within a function. Loops, functions, if, etc.

Any collection of curly braces

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

What does block scope mean?

A

variables within a function - denotated by curly braces

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

const keyword values can’t be reassigned.

Let can 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

The value in which the const variable references is changeable

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 a variable should be constant use const and if a variable needs to be mutable use let.

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