Node.js Flashcards
What is Node.js?
program that allows JavaScript to be run outside of a web browser.
What can Node.js be used for?
used for traditional web sites and back-end API services, but was designed with real-time, push-based architectures in mind
What is a REPL?
Read-eval-print loop
Interactive computer programming environment that takes a single user input, executes them, and returns the result to the user
When was Node.js created?
May 27, 2009
What back end languages have you heard of?
Ruby
Python
PHP
What is a computer process?
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)?
50+
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 at least an awareness of computer processes is necessary
What is the process object in a Node.js program?
is a global that provides information about, and control over, the current Node.js process
How do you access the process object in a Node.js program?
just use the process variable (it’s global)
What is the data type of process.argv in Node.js?
Array of strings
What is a JavaScript module?
a javascript file
What values are passed into a Node.js module’s local scope?
exports, require()
Give two examples of truly global variables in a Node.js program.
process, global
What is a directory?
is a special type of file that holds information about more directories and files
What is a relative file path?
a file relative to the current page
What is an absolute file path?
Any path that starts with a slash
What module does Node.js include for manipulating the file system?
We include the fs module
What method is available in the Node.js fs module for writing data to a file?
Node fs.writeFile
Are file operations using the fs module synchronous or asynchronous?
All the operations can be performed in a synchronous as well as in an asynchronous approach depending on the user requirements.
What is NPM?
a package manager for JavaScript: website, command line interface, and registry: shared data and packages, etc.
Node Package Manager
What is a package?
a folder containing a package.json program that lists the your projects dependencies
specifies versions of packages
makes your build reproducible, to share with other devs (directory with one or more files, and a package.json file)
How can you create a package.json with npm?
use the npm init command in the root directory of package
What is a dependency and how do you add one to a package?
packages that your project depends on,
you can list them as “dependencies” in package.json
What happens when you add a dependency to a package with npm?
the project will install all listed dependencies with the install command
How do you add express to your package dependencies?
npm install express automatically updates list of dependencies
What Express application method starts the server and binds it to a network PORT?
.listen()