ES6 Flashcards

1
Q

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

A

section of code enclosed within { }, ex: function, conditional, loop

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

What does block scope mean?

A

a value is only available within a certain 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-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 reassigned, const variables 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

you can’t reassign a const variable, but you can change the value of the variable

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

if a variable needs to be a reassigned, use let, otherwise 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

Use backticks instead of quotes

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

What is “string interpolation”?

A

replacing substitutions with the values of the variables and expressions

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

What is destructuring, conceptually?

A

taking apart an object or array and assigning the parts to different 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

let { prop1: var1, prop2: var2} = 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

let [ 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

it’s destructuring if the brackets are on the left of the assignment operator, creating if the brackets are on the right

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

( parameters ) => {statements};

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

without the curly braces, you can only have one expression

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

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

A

the value of this is determined by the value of this in its containing code block

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

What are the three states a Promise can be in?

A

pending (initial state), fulfilled (success), rejected (fail)

17
Q

How do you handle the fulfillment of a Promise?

A

.then ( onFulfilled, onRejected )

18
Q

How do you handle the rejection of a Promise?

A

.catch ( onRejected )

19
Q

What is “syntactic sugar”?

A

syntax that makes things easier to read or express

20
Q

What is the typeof an ES6 class?

A

function

21
Q

Describe ES6 class syntax.

A
class keyword ClassName {
   constructor(params) {
      this.prop = param;
      }
   functionName( ) {
      return this.prop;
   }
}
22
Q

What is “refactoring”?

A

restructuring code without changing functionality to improve design + structure

23
Q

How are ES Modules different from CommonJS modules?

A

syntax

24
Q

What kind of modules can Webpack support?

A

CommonJS, ESM, AMD, Assets, WebAssembly