ES6 Flashcards

1
Q

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

A

blocks are denoted by curly braces {} , for example, the 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

the variable only 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

blocked-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 variables can be updated but not re-declared; const variables can neither be updated nor re-declared.

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 can mutate the value of the const read-only reference but you cannot reassign it or redeclare 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

for global use var, for block-scope use let/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

wrap text in backticks

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

What is “string interpolation”?

A

${variable_name}

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

What is destructuring, conceptually?

A

assigning properties of objects to variables

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

const { property1: variable1, property2: variable2 } = 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

const [x, y, z] = 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

the name is on the right of assignment operator for CREATING objects/arrays.
the name is on left for DESTRUCTURING objects/arrays.

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, fulfilled, rejected

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

Promise.prototype.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

Promise.prototype.catch()

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

What is Array.prototype.filter useful for?

A

Creating a new array while excluding some elements.

17
Q

What is Array.prototype.map useful for?

A

Creating a new array containing the transformed elements of another.

18
Q

What is Array.prototype.reduce useful for?

A

Combining the elements of an array into a single value.

19
Q

What is “syntactic sugar”?

A

designed to make things easier to read or to express

20
Q

What is the typeof an ES6 class?

A

function

21
Q

Describe ES6 class syntax.

A

Class className {
constructer (parameters) {

}
method( ) { }
}

22
Q

What is “refactoring”?

A

the process of restructuring existing computer code without changing its external behavior