Node.js Flashcards
What is the process object in the 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().
How do you access the process object in a Node.js program?
Just call process.
What is the data type of process.argv in Node.js?
It returns an array containing the command line arguments when the Node.js process was launched. The first element will be process.execPath. The second element will be the path to the JS file being executed. The remaining elements will be any additional command line arguments.
What is process.execPath?
The process.execPath property returns the absolute pathname of the executable that started the Node.js process.
What is a JavaScript module?
In the Node.js module system, each file is treated as a separate module.
What values are passed into a Node.js module’s local scope?
exports (object), require (function), module (object), __filename (string), __dirname (string)
Give two examples of truly global variables in a Node.js program.
console, process
What is the JS Event Loop?
Its job is to continuously watch both the stack and message queue. When the stack becomes empty, it checks the message queue to see if there are any messages waiting to be processed. If there are, it puts them into the call stack one at a time and executes them. Each message is associated with a function such as a callback or an event.
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?
a full URL to a file
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?
fs.writeFile
Are file operations using the fs module synchronous or asynchronous?
asynchronous
What is JSON?
JSON is a text-based data format following JS object syntax, which was popularized by Douglas Crockford. JSON exists as a string.