ES6 Flashcards

1
Q

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

A

Anything enclosed in {}, example: if-else, for, do-while, while, try-catch.

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

What does block scope mean?

A

Variables or data that exists within the 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

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 variables cannot be reassigned, the values or properties inside a const variable can be changed but the not value of the variable cannot 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

Because const only sets a freeze to the top layer of a variable, the values inside of a const variable can change but not the variable itself.

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 the declaration to use?

A

Depending on the scope and how the variable will be used later on.

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

What is the syntax for writing a template literal?

A

backtick with the variable names in {} and $. Ex: Hi my name is ${firstName} ${lastName} -> ‘Hi my name is Jumanah Almajnouni’

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

What is “string interpolation”?

A

the ability to substitute part of the string for the values of variables or expressions

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