Node.js Flashcards
What is Node.js?
Program that allows JavaScript to run outside of a web-browser
What can Node.js be used for?
- Build back ends for web apps
- Command-line programs
- Any kind of automation that developers wish to perform
What is a REPL?
o Read-eval-print loop
o Interactive programming environment that takes single user inputs and executes them to return the result to the user (executed piecewise)
For example, the browser console
When was Node.js created?
2009
Back-end languages:
JavaScript Java Python PHP Ruby Go C++ C# (runs in .NET which is a framework)
What is a computer process?
Instance of a program running in a computer
Why should a full stack Web developer know that computer processes exist?
Because full stack web applications require multiple processes to work together concurrently for it to be useable (multiple processes have to be up and running to properly deal with the app’s clients, servers and databases)
What is the process object in a Node.js program?
Global object that provides information about/control over the current Node.js process
How do you access the process object in a Node.js program?
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?
o exports o require o module o \_\_filename o \_\_dirname
Give two examples of truly global variables in a Node.js program.
o console o process o Object o Undefined o global
What is the purpose of module.exports in a Node.js module?
How do you import functionality into a Node.js module from another Node.js module?
require(‘./filename’)
What is the JavaScript Event Loop?
How asynchronous callbacks are put back into the call stack when the call stack is clear
What is different between “blocking” and “non-blocking” with respect to how code is executed?
o Blocking = Stack is occupied and prevents other code from running (like for-loops)
o Non-blocking = Stack is clear and event loop can occur
What is a directory?
o Path to where the file is located
o Specific type of file that lists other files
What is a relative file path?
A path to a file starting from the current directory
What is an absolute file path?
A path to a file starting from the root (for windows, from the drive name)
What module does Node.js include for manipulating the file system?
fs (file system)
What method is available in the Node.js fs module for writing data to a file?
writeFile( )
Are file operations using the fs module synchronous or asynchronous?
Both
What is npm?
Makes it easier for javascript developers to share the code they have created to solve particular problems
o stands for node package manager
o Made of 3 parts: Website, CLI and registry