ES6 Flashcards
What are the three states a Promise can be in?
Pending: initial state, neither fulfilled nor rejected.
Fulfilled: meaning that the operation was completed successfully.
Rejected: meaning that the operation failed.
How do you handle the fulfillment of a Promise?
by using the then() method to have a callback function take action once its fulfilled.
How do you handle the rejection of a Promise?
catch( ) method
What is “syntactic sugar”?
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
What is the typeof an ES6 class?
function
Describe ES6 class syntax.
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
What is “refactoring”?
Rewriting code to make it more readable, while still maintaining the same functionality
How are ES Modules different from CommonJS modules?
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
What kind of modules can Webpack support?
ECMAScript modules CommonJS modules AMD modules Assets WebAssembly modules
ES, CommonJS, AMD