Node.js Flashcards
What is Node.js?
A program that allows JavaScript to run outside of a web browser.
What can Node.js be used for?
For creating the backend for web applications, writing command line programs, or some kind of automation.
What is a REPL?
Read-Eval-Print Loop (REPL) is an environment that takes single user inputs, executes them, and returns the results.
When was Node.js created?
2009.
What back end languages have you heard of?
JS, PHP, Ruby Python Lua
C#, F#, Visual Basic
Java, Kotlin, Clojure Groovy
What is the process object in a Node.js program?
It provides information about the current Node.js process.
How do you access the process object in a Node.js program?
Calling the log method of the console object with one argument, the ‘process’ variable.
What is the data type of process.argv in Node.js?
An array (of strings).
What is a JavaScript module?
A single .js file.
What values are passed into a Node.js module’s local scope?
__dirname, __filename, exports, module, require.
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?
To allow it’s information to be accessed by other Node.js modules.
How do you import functionality into a Node.js module from another Node.js module?
The require() function with a (string) parameter of the relative path of another Node.js module.
What is the JavaScript Event Loop?
It waits for tasks and executes them. If there are no tasks, then it “sleeps” until it receives another task.
It looks at the stack and task queue. If the stack is empty, it takes the first thing on the task queue and puts it on the stack (and runs it).
What is different between “blocking” and “non-blocking” with respect to how code is executed?
“Blocking” is executing code that prevents other code from executing until it is finished (“slow” or synchronous).
“Non-Blocking” is code that allows other code to execute while it is preparing itself to execute (“fast” or asynchronous).
What is a directory?
A structure of folders that also reference other folders.
What is a relative file path?
Shows how to get from the current working directory to the target file.
What is an absolute file path?
Shows how to get from the root directory to the target file.