node.js Flashcards
What is a CLI?
command line interface
What is a GUI?
graphical inter user face
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 -> see the contents of files ls -> shows list of directories/files of current branch pwd -> shows current branch echo -> 'text' appears on terminal touch -> creates a file mkdir -> creates a directory/folder mv -> move or rename a file rm -> remove (danger)!! cp -> copy
What are the three virtues of a great programmer?
laziness, impatience, and hubris
What is Node.js?
javascript environment that is not in a browser
What can Node.js be used for?
anything you can do with programs
What is a REPL?
request and sends such as javascript console log
When was Node.js created?
2009
What is the process object in a Node.js program?
data model of running program
What is the data type of process.argv in Node.js?
object of an array with strings
How do you access the process object in a Node.js program?
process.argv[2,3,4,…]
for loop i starts 2 not 0
What is a JavaScript module?
js files that are in the directories
What values are passed into a Node.js module’s local scope?
object, exports, require, __dirname, __filename, module
Give two examples of truly global variables in a Node.js program.
process, global
What is the JavaScript Event Loop?
function executes and if send request -> put it aside and when receive it put in on queue and runs when the stack is cleared
What is different between “blocking” and “non-blocking” with respect to how code is executed?
blocking -> if executing functions, cannot run other function
non-blocking -> event-loop
What is a directory?
folder that contains files
What is a relative file path?
location that is relative to a current directory
What is an absolute file path?
the root element and the complete directory list required to locate the file.
What module does Node.js include for manipulating the file system?
‘fs’
What method is available in the Node.js fs module for writing data to a file?
Use JSON.stringify(data, null, 2)
(2 is indentation)
fs.writefile(‘filename’, data, ‘utf8’, callback function)
ex. const stringjson = JSON.stringify(json, null, 2);
fs.writeFile(‘data.json’, stringjson, ‘utf8’, err => {
if (err) {
Are file operations using the fs module synchronous or asynchronous?
both
Which HTTP method does a browser issue to a web server when you visit a URL?
GET
What is on the first line of an HTTP response message?
version, status code, status message
What are HTTP headers?
meta data
Is a body required for a valid HTTP message?
no because it appears after header