ES6 Promises, Classes, and Modules 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?
You call the then method of the promise object with a callback function
How do you handle the rejection of a Promise?
You call the catch method of the promise object with a callback function
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?
A Function
Describe ES6 class syntax.
class Person { constructor(name) { this.name = name; } function() { function code } }
What is “refactoring”?
Refactoring is re-writing code for readability and useability with abstraction while not changing the behavior
How are ES6 Modules different from CommonJS modules?
ES6 Modules are pre-parsed in order to resolve further imports before code is executed.
CommonJS modules load dependencies on demand while executing the code.
const varName = require(‘./file-path’); → import class/functionName from ‘./file-path’;
What kind of modules can Webpack support?
ES6, CommonJS, and AMD Modules