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?
Promise.protoype.then() method
The then method handles both fulfillment and rejection values of the promise
How do you handle the rejection of a Promise?
promise.prototype.catch or promise.prototype.then methods can handle rejection of a promise
What is “syntactic sugar”?
syntax within a programming language that is designed to make things easier to read or to express
What is the typeof an ES6 class?
ES6 are syntactic sugar for the constructor function
Describe ES6 class syntax.
class keyword + name of class + { + constructor +prototype methods + }
What is “refactoring”?
How are ES Modules different from CommonJS modules?
Syntax is more compact than CommonJS
Structure can be statically analyzed (for static checking, optimization, etc.)
Support for cyclic dependencies is better than CommonJS’s
What kind of modules can Webpack support?
ES modules, CommonJS modules, and AMD modules
What does fetch( ) return?
fetch returns a promise object which eventually becomes fulfilled
What is the default request method used by fetch( )?
default request method is GET
How do you specify the request method (GET, POST, etc.) when calling fetch?
fetch( path, { method: ‘GET’ })