Node.js Flashcards
What is a CLI?
What is a GUI?
command line interface
graphical user interface
Give at least one use case for each of the commands listed in this exercise. man cat ls pwd echo touch mkdir mv rm cp
man - manual
cat - read files and “concatenate files”
ls - list files – options -aF to show all and any files starting with .
pwd - print working directory
echo - echos a string
touch - alters a file or directory - make blank file
mkdir - make directory – options -p to include parent directories
mv - move or rename files
rm - remove files –> rm -r remove directory -f force
cp - copy file
What is Node.js?
asynchronous event-driven JavaScript runtime
What can Node.js be used for?
used for server-side programming, and primarily deployed for non-blocking, event-driven servers, such as traditional web sites and back-end API services
What is a REPL?
read, evaluate, print, loop
where you can do calculations and stuff in a ‘terminal’
When was Node.js created?
2009
What is the process object in a Node.js program?
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?
type process in node command
What is the data type of process.argv in Node.js?
strings in an array
–> string array
What is a JavaScript module?
smaller JS files that do a specific thing and put together to do “somethign” as a whole
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.
process and global, console
What is the purpose of module.exports in a Node.js module?
allows the function to be import as module using require
How do you import functionality into a Node.js module from another Node.js module?
require()
What is the JavaScript Event Loop?
consists of stack, heap, and queue
code is put through a stack and uses last in first out to return functions/modules, if there is any async functions/ http requests then it goes to the heap and then once it checks out it goes to the queue. Once the stack is empty it then puts the first item from the queue to the stack then returns it