Node Flashcards
What is Node.js?
A program that allows you to run JavaScript outside of a web browser
What can Node.js be used for?
To build scalable network applications
When was Node.js created?
2009
What back end languages have you heard of?
PHP, C+, C++, C#, Java, Ruby, Python, Perl
What is a computer process?
The instance of a computer program that is being executed by one or many threads. Contains program code and it’s activity
Roughly how many computer processes are running on your host operating system (Task Manager or Activity Monitor)?
About 2,000 or more
Why should a full stack Web developer know that computer processes exist?
To make sure their program works!
What is the process object in a Node.js program?
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?
It’s always available because it is a GLOBAL
What is the data type of process.argv in Node.js?
It returns an array containing the command line arguments passed when the Node.js process was launched
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
setTimeOut, setInterval, console, global
What is the purpose of module.exports in a Node.js module?
Specify what variables/functions you want to make available for other modules
export is an object, so you can export properties
How do you import functionality into a Node.js module from another Node.js module?
by calling the require() function
What is the JavaScript Event Loop?
The Event Loop has one simple job — to monitor the Call Stack and the Callback Queue. If the Call Stack is empty, it will take the first event from the queue and will push it to the Call Stack, which effectively runs it. Such an iteration is called a tick in the Event Loop. Each event is just a function callback.
What is difference between “blocking” and “non-blocking” with respect to how code is executed?
Blocking methods execute synchronously and non-blocking methods execute asynchronously.
Blocking is when the execution of additional JavaScript in the Node.js process must wait until a non-JavaScript operation completes. This happens because the event loop is unable to continue running JavaScript while a blocking operation is occurring.
What is a directory?
A directory is a logical grouping of files. Directories are called folders
In computing, a directory is a file system cataloging structure which contains references to other computer files, and possibly other directories. On many computers, directories are known as folders
What is a relative file path?
A relative file path points to a file relative to the current page
What is an absolute file path?
An absolute file path is the full URL to a file
What module does Node.js include for manipulating the file system?
the fs module
What method is available in the Node.js fs module for writing data to a file?
the writeFile() method
Are file operations using the fs module synchronous or asynchronous?
Asynchronous