Node.js 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.
What is a REPL?
Read-eval-print-loop
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
How do you access the process object in a Node.js program?
simply process
What is the data type of process.argv in Node.js?
Array of strings
What is a JavaScript module?
a single js file
What values are passed into a Node.js module’s local scope?
module, exports, require, __filename, __dirname
Give two examples of truly global variables in a Node.js program.
process, console, global
What is the purpose of module.exports in a Node.js module?
so that we can import using require function
How do you import functionality into a Node.js module from another Node.js module?
use require function with path to file
What is the JavaScript Event Loop?
Event loop is something that monitors the Call Stack and the Callback Queue. If the Call Stack is empty, the first event from the queue is pushed to the Call Stack.
What is different between “blocking” and “non-blocking” with respect to how code is executed?
blocking is when call stack is not empty and is being processed for a long time. non-blocking is multiple Callbacks queued so that event loop can effectively handle code.
What module does Node.js include for manipulating the file system?
file system (fs/fs.js)
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?
Asynchronous with callback functions