es6 Flashcards

1
Q

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

A

defined statements that are executed together

{anything inside 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

A block scoped variable means that the variable defined within a block will not be accessible from outside 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 scope

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 can be redeclared but const can’t

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

we can change the arrays elements but we can’t change the arrays variable name

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

depending on weather you plan on mutating that variable or not

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

``

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

What is “string interpolation”?

A

adding variables to strings ${}

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

What is the syntax for defining an arrow function?

A

()=>{}

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

When an arrow function’s body is left without curly braces, what changes in its functionality?

A

you can only have one expression not multiple also it automatically returns the result without the return statement

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

How is the value of this determined within an arrow function

A

its value within the arrow function is determined by the surrounding scope
example::
To fix this, you assign the this value to a variable that doesn’t shadow inside the anonymous function as follows:

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

What is destructuring, conceptually?

A

extracting data from arrays or objects

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

What are the three states a Promise can be in?

A

pending: initial state, neither fulfilled nor rejected.
fulfilled: meaning that the operation was completed successfully.
rejected: meaning that the operation failed

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

How do you handle the fulfillment of a Promise?

A

then

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

How do you handle the rejection of a Promise?

A

catch or then with a second callback funtion to handle the rejection

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