Node.js Flashcards
What is Node.js?
an asynchronous event-driven JavaScript runtime environment that executes
JavaScript code outside a web browser.
What can Node.js be used for?
foundation of a web library or framework used for back-end application
What is a REPL?
Read–eval–print loop - a simple interactive computer programming environment that takes single user inputs, executes them, and returns the result to the user
When was Node.js created?
2009
What back end languages have you heard of?
Python, PHP, Ruby
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)?
100+
What is the process object in a Node.js program?
a global variable 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?
each JavaScript file is a module
What values are passed into a Node.js module’s local scope?
exports, require(), module, __dirname, __filename
Give two examples of truly global variables in a Node.js program.
process, console
What is the purpose of module.exports in a Node.js module?
to use variables and functionalities from other modules
How do you import functionality into a Node.js module from another Node.js module?
require(‘relative file path’)
What is the JavaScript Event Loop?
monitors the Call Stack and the
Callback Queue.
If the Call Stack is empty, it will take the first event from the
Callback queue and will push it to the Call Stack, which effectively runs it
What is different between “blocking” and “non-blocking” with respect to how code is executed?
blocking code is executed in sequence – each statement waits for the previous statement to finish before executing
non-blocking code doesn’t have to wait – your program can continue to run
What is a directory?
A folder
What is a relative file path?
file path from the current working directory
What is an absolute file path?
file path from the root directory
root === /
What module does Node.js include for manipulating the file system?
File System (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?
both, depends on which one you use