Node intro, process, process.argv, modules, fs-read/writefile Flashcards
What is Node.js?
JavaScript runtime built on Chrome’s V8 JavaScript engine
What can Node.js be used for?
To build scalable network applications
Write your code in JavaScript and execute it with node
What is REPL?
Read-eval-print loop
Simple interactive computer programming environment that takes single user inputs, executes them, and returns the result to the user
A program written in a REPL environment is executed piecewise
What is a computer process?
A process is the instance of a computer program that is being executed by one or many threads. It contains the program code and its activity.
Why should a full stack Web Developer know that computer processes exist?
Full stack web development is based on making multiple processes work together to form one application
What is the process object in a 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?
It’s included in the global. You can use it any time by name.
What is the data type of process.argv in Node.js?
An array of strings
What is a JavaScript Module?
A JavaScript module is a example.js file
What values are passed into a Node.js module’s local scope?
__dirname
The directory of the current model
__filename
The file name of the current module
exports
A reference to the module.exports (exports a file)
module
A reference to the current module
require()
Used to import modules, JSON, and local files
Give two examples of truly global variables in a Node.js program.
global.process
Global.global
What is the purpose of module.exports in a Node.js module?
It allows other files/nodes to access the the exported function, string, variable etc
How do you import functionality into a Node.js module from another Node.js module?
Const name = require(‘.module’)
Use the require function
What is a directory?
A file system cataloging structure which contains references to other computer files, and possibly other directories
A file to point to other files, a place in a file system that stores other files
What is a relative file path?
A relative file path is a folder within the current directory