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?
object.then(value => {
console.log(value);
};
How do you handle the rejection of a Promise?
object.catch(error => {
console.log(error or error.message)
};
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?
Function.
Describe ES6 class syntax
Class keyword Name of class Opening curly brace for class declaration Constructor and Method definitions Closing curly brace for class declaration
What is “refactoring”?
Restructuring existing code without changing its external behavior.
How are ES modules different from CommonJS modules?
They syntax is more compact
Their structure can be statically analyzed (for static checking, optimization, etc.).
Their support for cyclic dependencies is better than CommonJS’s.
What kind of modules can Webpack support?
ECMASCript modules CommonJS modules AMD modules Assets WebAssembly modules
Describe importing a module.
Import keyword
opening curly brace { if not a default import
Comma separated names of imports
Closing curly brace } if not a default import
From keyword
Directory string in parenthesis.
Describe exporting a module.
Export keyword
If default add Default keyword. Only one per module
Either the variable name or the code block being exported.