es6 Flashcards

1
Q

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

A

an area within curly braces with the exception of a for loop. Some examples are functions definitions and for loops.

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

What does block scope mean?

A

if it’s inside the code block it stays in 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

block scoped which means they stay within the code block.

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 reassigned and const 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

you are not re-assigning the array itself, but instead adding to it.

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

use const and let the compiler tell you if you are unsure which declaration to use. If it is gonna be reassigned use let if not use const.

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

backticks and $ and curly braces for substitutions.

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

What is “string interpolation”?

A

The substitutions allow you to embed variables and expressions in a string. The JavaScript engine will automatically replace these variables and expressions with their values.

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

What is destructuring, conceptually?

A

taking parts of it out and re-assigning them

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

What is the syntax for Object destructuring?

A

keyword const or let, curly braces, property name, =, and name of original object

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

What is the syntax for Array destructuring?

A

keyword const or let, square bracket, name of element at index, =, name of original array

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

How can you tell the difference between destructuring and creating Object / Array literals?

A

which side the equal sign is on the variable name. Left side is destructuring and right side is creating.

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

What is the syntax for defining an arrow function?

A

() => with or without curly braces

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

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

A

returns the expressions without curly braces only one expression is returned

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

What are the three states a Promise can be in?

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

How do you handle the fulfillment of a Promise?

A

Promise.then()

17
Q

How do you handle the rejection of a Promise?

A

Promise.catch()

18
Q

What are JavaScript classes?

A

template for

19
Q

When would you want to use a class?

A

so you can encapsulate all the functionality in one place

20
Q

How do you declare a class?

A
21
Q

How do you inherit from another class?

A
22
Q

Why would you want to inherit from another class?

A

to keep the object and all its methods relatively small also for reusability

23
Q

How do you add methods and properties to a class?

A

add the method in the code block