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?
You call .then( ) on a Promise and then you pass in a callback that expects up to one parameter, the value it results to and then that will tell it what to do
How do you handle the rejection of a Promise?
What is “syntactic sugar”?
In computer science, syntactic sugar is syntax within a programming language that is designed to make things easier to read or to express. It makes the language “sweeter” for human use: things can be expressed more clearly, more concisely, or in an alternative style that some may prefer. Syntactic sugar is usually a shorthand for a common operation that could also be expressed in an alternate, more verbose, form: The programmer has a choice of whether to use the shorter form or the longer form, but will usually use the shorter form since it is shorter and easier to type and read.
What is the typeof an ES6 class?
function
Describe ES6 class syntax.
class Person {
constructor(name) {
this.name = name;
}
getName( ) {
return this.name;
}
}
What is “refactoring”?
code refactoring is the process of restructuring existing computer code—changing the factoring—without changing its external behavior. Refactoring is intended to improve the design, structure, and/or implementation of the software (its non-functional attributes), while preserving its functionality. Potential advantages of refactoring may include improved code readability and reduced complexity; these can improve the source code’s maintainability and create a simpler, cleaner, or more expressive internal architecture or object model to improve extensibility. Another potential goal for refactoring is improved performance; software engineers face an ongoing challenge to write programs that perform faster or use less memory.
How are ES Modules different from CommonJS modules?
Different syntax
CommonJS modules load using require(), and variables and functions export from a CommonJS module with module.exports.
ES Modules load using import & export statements
What kind of modules can Webpack support?
Natively supports:
- ECMAScript modules
- CommonJS modules
- AMD modules
- Assets
- WebAssembly modules