es6 Flashcards

1
Q

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

A

code wrapped in curly braces ({}). if, if else, while, etc.

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

What does block scope mean?

A

Only accessible inside of 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 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

A constant variable cannot be reassigned. let variables 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

The value inside the array is not immuatable

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 let const unless you cant, then use let

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

What is destructuring, conceptually?

A

Assigning properties of an object or elements of an array to individual 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

const/let {} = obj

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

const let [] = obj

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

an object literal / array literal is assigned to a variable in creation. In destructuring, the name of the created object/array is assigned to an object/array containing the variables.

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

What is the syntax for writing a template literal?

A

` ` and use ${} for string interpolation

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

What is “string interpolation”?

A

the ability to substitute part of the string for the values of variables or expressions

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

functionName = (parameters) => {expression}.

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

Curly braces are not needed unless there is a statement being used

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

By where it is defined, not by who calls it

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, neither fulfilled nor rejected.
fulfilled: meaning that the operation was completed successfully.
rejected: meaning that the operation failed.

17
Q

How do you handle the fulfillment of a Promise?

A

then( ) method

18
Q

How do you handle the rejection of a Promise?

A

catch( ) method

19
Q

What is “syntactic sugar”?

A

syntax within a programming language that is 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 Animal {
    constructor(type) {
        this.type = type;
    }
    identify() {
        console.log(this.type);
    }
}
22
Q

What is “refactoring”?

A

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

23
Q

How are ES Modules different from CommonJS modules?

A

Their syntax is even more compact than CommonJS’s.
Their structure can be statically analyzed (for static checking, optimization, etc.).
Their support for cyclic dependencies is better than CommonJS’s.

24
Q

What kind of modules can Webpack support?

A
ECMAScript modules
CommonJS modules
AMD modules
Assets
WebAssembly modules