ES6 Flashcards

1
Q

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

A

A block of code within 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

variables and functions are only accessible within the block/function

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

Is changes the the value, doesn’t reassign the constant

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

When you want to reassign, use let

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

What is destructuring, conceptually?

A

Extracting multiple values from data stored in objects and arrays and storing them in variables.

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

What is the syntax for Object destructuring?

A

let/const { } = name of object

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

What is the syntax for Array destructuring?

A

let/const [ ] = name of array

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

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

A

Left hand side = for object literals, Right hand side = for destructuring

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

What is the syntax for defining an arrow function?

A

let something = (x, y) => x + y;
let something = (x, y) => { return x + y; };
numbers.sort((a, b) => a - b);

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

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

A

You need to specify the return statement

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

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

A

By the surrounding scope (parent)

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

How do you handle the rejection of a Promise?

A

catch()

17
Q

What is syntactic sugar?

A

Syntax easier to understand. “Not ugly”

18
Q

What is the typeof an ES6 class?

A

object

19
Q

What is refactoring?

A

modifying code, without changing its behavior

20
Q

What kind of modules can Webpack support?

A

ECMAScript modules. CommonJS modules. AMD modules.