es6-const-let Flashcards

1
Q

What is a code block?

A

Code blocks are function declarations between an opening and closing curly brace. For loops, if else statement, while loops, etc
OR grouped statements within curly braces or any collection of curly braces.

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

What are some examples of a code block?

A

functions, objects

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

What does block scope mean?

A

It means that the area where declared variables exist and are available for use, usually within the confines of a code block

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

What is the scope of a variable declared with const or let?

A

Block scope. Only attached to the code block it exists in. A block is a chunk of code bounded by {}.

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

What is the difference between let and const?

A

The const variable cannot be reassigned or updated while let can

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

Why is it possible to .push() a new value into a const variable that points to an Array?

A

While it’s the object or array stored cannot be reassigned, they are not immutable as the value of each properties in a const variable can be reassigned.

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

How should you decide on which type of declaration to use?

A

Use const unless you can’t.

Will the value need to be attached to the global object? Use a var.
Will the value need to be reassigned only? Use a let.
Will the value not need to be reassigned only? Use a const.
Es6-destructuring

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