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?
Use then( ) method
How do you handle the rejection of a Promise?
Use then( ) method or catch( ) method
What is “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.
What is thetypeofan ‘ES6 class’?
The class declaration is just syntactic sugar of the constructor function, therefore, the result of the ‘typeof’ operator of ES6 class is function.
Describe ES6 class syntax.
Class keyword followed by curly braces for the class declaration
What is “refactoring”?
Code refactoring is the process of restructuring existing computer code—changing the factoring—without changing its external behavior; preserve functionality
What doesfetch()return?
fetch()takes one argument — the path to the resource you want to fetch — and returns a promise containing aResponseobject.
What is the default request method used byfetch()?
Get
How do you specify the request method (GET,POST, etc.) when callingfetch?
By having a second parameter as an object containing the method request)