Node.js + NPM + Express Flashcards
What is Node.js?
a program that allows JavaScript to be run outside of a web browser
commonly used to build back ends for Web applications, command-line programs, or any kind of automation that developers wish to perform
powered by V8– the same JavaScript engine in the Google Chrome browser
its primary focused on creating simple, easy-to-build network clients and servers
What can Node.js be used for?
primarily used for non-blocking, event-driven servers, due to its single-threaded nature
It’s used for web sites and back-end API services
used for outside of the browser
What is a REPL?
read–eval–print loop (REPL) is a simple interactive computer programming environment that takes single user inputs, executes them, and returns the result to the user
simply type the node command to initiate the REPL session
When was Node.js created?
2009
What is a computer process?
the instance of a computer program that’s being executed by one or many threads (running tasks)
instance of a running program
threading- how the cpu remembers what it was doing
Why should a full stack Web developer know that computer processes exist?
Full stack Web development is based on making multiple processes work together to form one application, so having knowledge of computer processes is important
if were writing front end code and the site is connecting to backend, we have to know how to work with backend (node.js, postgress) as well, thats multiple process
What is the process object in a Node.js program?
The PROCESS object is a GLOBAL OBJECT 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()
you can handle command line arguments with the process object using process.argv
How do you access the process object in a Node.js program?
just typing process in the terminal/console since process is a global object
What is process.argv in Node.js? And what does it return?
process.argv returns an array containing the command line arguments passed when the Node.js process was launched
returns an array of strings
What is a JavaScript module?
in JS, a module is a single .js file
Node.js supports modules using a system heavily influenced by CommonJS
Authors of Node.js programs strive to separate their code into modules that each provide a small chunk of functionality
The program as a whole is the result of all of these modules working together in concert.
What values are passed into a Node.js module’s local scope?
exports, require, module, __filename, __dirname
directory and file name of the current module
Give two examples of truly global variables in a Node.js program.
processed, console
What is the purpose of module.exports in a Node.js module?
to export the current file its in
allows variables from one file to be used in another file
How do you import functionality into a Node.js module from another Node.js module?
with required() and passing in a relative path to the file
What is the JavaScript Event Loop?
event loop’s job is to look at the stack and the task queue, if the stack is empty, it takes the first thing on the queue and pushes onto the stack then runs the code in the stack
What is different between “blocking” and “non-blocking” with respect to how code is executed?
blocking executes the code in series. You cant continue until an operation (http request for ex) is complete
In Node.js doc: blocking is when the execution of additional JavaScript in the Node.js process must wait until a non-JavaScript operation completes.
non-blocking refers to code that doesn’t block execution
blocking methods execute synchronously while non-blocking methods execute asynchronously
What is a directory?
is known as a folder or a collection or files
What is a relative file path?
a location in the current working directory (or the present working directory/ pwd)
relative paths make use of two special symbols, a dot (.) and a double-dot (..), which translate into the current directory and the parent directory