Node Flashcards
What is Node.js?
program that lets JavaScript to be run outside of a web browser
What can Node.js be used for?
build back end for Web applications, command-line programs, or any kind of automation that developers wish to perform
What is a REPL?
read-eval-print loop
takes input, reads and executes it, then returns the result to the user
When was Node.js created?
2009
What back end languages have you heard of?
Python, C, C++, java, C#, PHP, JavaScript, Go, Rust, Assembly
What is a computer process?
a computer program being executed
Roughly how many computer processes are running on your host operating system (Task Manager or Activity Monitor)?
~300
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 a cursory 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?
console.log(process);
What is the data type of process.argv in Node.js?
array
What is a JavaScript module?
a single JavaScript file
What values are passed into a Node.js module’s local scope?
exports, require, module, __filename, __dirname
Give two examples of truly global variables in a Node.js program.
process and console
What is the purpose of module.exports in a Node.js module?
instructions/command that tells node.js which bits of code can be exported so that other files may access them
How do you import functionality into a Node.js module from another Node.js module?
require(./filename)
./ looks in current directory
What is the JavaScript Event Loop?
thing that looks at the stack and pushes first item in the queue to the stack IF the stack is empty
What is different between “blocking” and “non-blocking” with respect to how code is executed?
blocking occurs when an item in the stack takes a while and stalls the program - this can happen in synchronous codes
non-blocking executes “multiple threads” at a time by utilizing browsers to manage asynchronous codes (callbacks)
What is a directory?
a collection of files
What is a relative file path?
path to the file from the current directory
What is an absolute file path?
path to the file from the root
filepath starts with ‘/’ and only that
What module does Node.js include for manipulating the file system?
fs
What method is available in the Node.js fs module for writing data to a file?
fs.writeFile
Are file operations using the fs module synchronous or asynchronous?
both, they have synchronous and asynchronous methods