Node Flashcards
What are the 3 components of a fullstack Web architecture?
Front-end server, application server, back-end server.
What is Node.js?
Node.js is a back-end JavaScript runtime environment
What can Node.js be used for?
back-end
What is a REPL?
Read-Eval-Print-Loop (REPL) is an easy-to-use command-line tool, used for processing Node. js expressions
When was Node.js created?
May 27, 2009
What backend languages have you heard of?
Python, PHP, Ruby, Java, C++
What is a computer process?
a process is the instance of a computer program that is being executed by one or many threads.
Roughly how many computer processes are running on your host operating system (Task Manager or Activity Monitor)?
100+
Why should a full stack Web developer know that computer processes exist?
What is the process object in a Node.js program?
The process object is a global that provides information about, and control over, the current Node.js process. As a global, it is always available to Node.js applications without using require(). It can also be explicitly accessed using require():
How do you access the process object in a Node.js program?
console.log(process)
What is the data type of process.argv in Node.js?
an Array of strings
How do you access the command line arguments in a Node.js program?
What is a JavaScript module?
What are the advantages of modular programming?
In JavaScript, how do you make a function in a module available to other modules?
export keyword
In JavaScript, how do you use a function from another module?
import keyword.
What is the JavaScript Event Loop?
What is different between “blocking” and “non-blocking” with respect to how code is executed?
Blocking refers to operations that block further execution until that operation finishes while non-blocking refers to code that doesn’t block execution. Or as Node. js docs puts it, blocking is when the execution of additional JavaScript in the Node. js process must wait until a non-JavaScript operation completes.
What is a directory?
a folder/container that holds files.
What is a relative file path?
a file in the same directory
What is an absolute file path?
always starts at the root of the file path.
What module does Node.js include for manipulating the file system?
fs-module
What method is available in the node:fs module for reading data from a file?
readFile(FILEPATH, OPTION)
What method is available in the node:fs module for writing data to a file?
writeFile(fileneame, data)
Are file operations using the fs module synchronous or asynchronous?
asynchronous because file operations are slow. So they are asynchronous to avoid blocking.
What is NPM?
Node Package Manager.
What is a package?
A directory with one or more files that usually have bit of code inside.
How can you create a package.json with npm?
npm init –yes
What is a dependency and how do you add one to a package?
its a package that you depend on. npm install package-name
What happens when you add a dependency to a package with npm?
Adds package name into dependencies field into package.json and creates a node_modules directory where the package is put and its dependencies.
What are some other popular package managers?
Yarn, PNPM,
What is Express useful for?
Useful for implementing routes or endpoints.
How does Express fit into a full-stack web application?
On server side, manages the http requests.
How do you add express to your package dependencies?
npm install express
What Express application method starts the server and binds it to a network PORT?
the listen() method
a port is an endpoint of a communication in an operating system. Specific port numbers are often used to identify specific services.
What is Express middleware?
a function that takes in a request, does something, then calls next or response.
What is Express middleware useful for?
changing http requests and then returning a response???
How do you mount a middleware with an Express application?
Pass the middleware function through app.use
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
the request, the response, and the next function
What is an API endpoint?
a URL with API at the end.
the endpoint is the end of the URL.
What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?
application/json
What is the purpose of the Express Static middleware?
To serve static files such as images, CSS files, and JavaScript files, use the express.static built-in middleware function in Express. Express static sets up middleware that checks to see if a file exists and then calls sendFile on it.
What does express.static() return?
a middleware function.
What are several examples of static files?
Any kind of file can be served as static content as long as it does not change in response to a user’s actions or inputs. This includes images, JavaScript files, CSS files, videos, Flash files, even web pages.
What is a good way to serve application images using Express?
use the express.static built-in middleware function