ES6 Flashcards

1
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
2
Q

How do you handle the fulfillment of a Promise?

A

by using the then() method to have a callback function take action once its fulfilled.

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

How do you handle the rejection of a Promise?

A

catch( ) method

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

What is “syntactic sugar”?

A

syntax within a programming language that is designed to make things easier to read or to express.

is a way to use shortcuts in programming language which makes complex code easy to read and write

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

What is the typeof an ES6 class?

A

function

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

Describe ES6 class syntax.

A

Use the class keyword followed by the name of the class, followed by curly braces. Inside the curly braces you can include an optional constructor function where you can add the properties of an instance and you can also add optional prototype method definitions.

class Animal {
constructor(type) {
this.type = type;
}
identify() {
console.log(this.type);
}
}

You define a class, and inside that class you define a constructor function where you pass the parameters you’re expecting, and then you can define multiple methods that you would want to run on that class

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

What is “refactoring”?

A

Rewriting code to make it more readable, while still maintaining the same functionality

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

ES Modules syntax is more compact than CommonJS, structure can be statically analyzed, the support for cyclic dependencies is better than CommonJS

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

What kind of modules can Webpack support?

A
ECMAScript modules
CommonJS modules
AMD modules
Assets
WebAssembly modules

ES, CommonJS, AMD

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