What does synchronous mean?
To be in a sequence such that every statement of the code is executed one by one.
A statement must wait for the earlier statement to complete
What does asynchronous mean?
To allow the program to be executed immediately without waiting for the earlier statement to complete
What is a Promise?
A JavaScript object that represents the eventual completion of an asynchronous operation and its resulting value.
It links the “producing code” and the “consuming code” together
How is a Promise like a proxy?
It allows you to associate handlers with an asynchronous action’s event on success or failure
What are the possible states of a promise?
What are the restrictions on promises moving between states?
What are the benefits of using Promises?
What arguments does the Promise constructor take?
Takes one argument which is a callback function
What arguments does the Promise callback function take?
What are the 3 main Promise instance methods?
What are the parameters accepted by the Promise’s then() method?
Takes 2 functions
1. Executed if the promise is resolved and a result is received
2. Executed if the promise is rejected and an error is received
What parameters are accepted by the catch() method?
Takes one function which is called when the promise is rejected
Since JavaScript already has try catch why does Promise need its own catch?
What parameters are accepted by the finally() method?
Takes one function that is called when the Promise is resolved or rejected
What are the 3 main Promise static methods?
What parameters are accepted by the all() method?
Takes an array of promises. It waits for all of the promises in the array to resolve or one of them to fail before calling the then() or catch() methods
What parameters are accepted by the any() method?
Takes an array of promises. As soon as one promise fulfills it returns a single promise that resolves with the value from that finished promise
What parameters are accepted by the race() method?
Takes an array of promises. It will wait until any one of the promises is fulfilled or rejected
What is the difference between an instance method and a static method?
What is node.js
Allows you to run JavaScript on a web server. It can generate dynamic page content; can create, open, read, write, delete, and close files on the server; can collect form data; can add, delete, and modify data in a database
How do you run JavaScript from the command line with node?
Using the node keyword:
node FileName.js
What does REPL stand for and what does it allow you to do?
Stands for Read, Evaluate, Print, Loop
Allows you to enter JavaScript commands, evaluate them, print results, and loop to enter another command
How do you access modules that are not built-in to node.js?
Using the require keyword
Ex:
var mod = require(“module”);
What is the HTTP module?
Allows node.js to transfer data using HTTP protocol. Makes node.js into a web server