ES6 Flashcards

1
Q

What is destructuring, conceptually?

A

Assigning properties of an object to individual variables.

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

What is the syntax for Object destructuring?

A

let/const followed by opening curly brace, the property name followed by a colon, followed by the variable name. Then closing curly brace for the code block. Then assignment operator with name of object to destructure.

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

What is the syntax for Array destructuring?

A

let/const followed by opening square bracket, variable names separated by commas, followed by the closing square bracket. Followed by the assignment operator and the array to destructure.

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

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

A

In destructuring, the assignment operator appears after the curly braces. (variable name after assignment operator.)

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

What is the syntax for writing a template literal?

A

Backticks instead of quotes or double-quotes. Designate a JavaScript expression by using dollar sign then curly braces.

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

What is “string interpolation”?

A

Embedding variables and expressions into strings.

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

What is the syntax for defining an arrow function?

A

parameter list first, enclosed in parentheses; Followed by arrow ( => ), followed by code statements enlosed in curly braces.

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

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

A

Without braces, you can only use an single-line expression in the body of the arrow function.

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

How is the value of this determined within an arrow function?

A

An arrow function captures the ‘this’ value of its enclosing context.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
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
11
Q

How do you handle the fulfillment of a Promise?

A

By adding a callback function as the first argument in its ‘then’ method.

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

How do you handle the rejection of a Promise?

A

By adding a callback function as the second argument in its ‘then’ method.

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

What is Array.prototype.filter useful for?

A

It’s useful for getting just the values you need out of an array and ignoring the rest.

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

What is Array.prototype.map useful for?

A

It’s useful for calling a function on every element of an array and assigning the results to a new array, without modifying the original.

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

What is Array.prototype.reduce useful for?

A

It’s useful for calling a function on every element of an array and storing the combined result in a single output value. | | For getting a combined value from an array.

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

What is “syntactic sugar”?

A

Syntactic sugar is syntax within a programming language that is designed to make things easier to read or to express. It does not change the behavior of the code.

17
Q

What is the typeof an ES6 class?

A

An object (function).

18
Q

Describe ES6 class syntax.

A

class keyword, followed by the class name, followed by a curly brace for the class declaration, then an optional constructor method, where you can define any properties of an instance, (passing any parameters into the constructor parameter list) then any methods after that.

19
Q

What is “refactoring”?

A

Code refactoring is the process of restructuring existing computer code—changing the factoring—without changing its external behavior.