SeniorSide Flashcards
What are the three great virtues of a programmer?
Laziness, Impatience, Hubris
Name at least one use case for each of the commands listed in this exercise.
Cat- print contents of something
Ls- see the contents of current directory
Pwd- see the path of where you are
Echo- command line version of console.log
Touch- if touch a file that doesn’t exist then it gets created. Otherwise, its access time gets updated to right now
Mkdir- make new directory
Mv- renaming files or moving files
Rm- deleting or remove files, but if directory then use -r
Cp- copy a file
What is a GUI?
“gooey” graphical user interface. Ex. Finder in mac is a GUI for manipulating file system or file explorer in windows
What is a CLI?
Command line interface
What is Array.prototype.filter useful for?
creates a new array while excluding certain items
What is Array.prototype.map useful for?
creates a new array with transformed array elements
What is Array.prototype.reduce useful for?
combines the items of array into a single thing
What is Node.js?
A program that allows Javascript to be run outside of a web browser
What can Node.js be used for?
It is commonly used to build back ends for Web applications, command-line programs, or any kind of automation that developers wish to perform.
What is a REPL?
A read–eval–print loop (REPL), also termed an interactive toplevel or language shell, is a simple, interactive computer programming environment that takes single user inputs (i.e., single expressions), evaluates (executes) them, and returns the result to the user; a program written in a REPL environment is executed piecewise.
When was Node.js created?
2009
What back end languages have you heard of?
node.js, Python, PHP, Ruby
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. Depending on the operating system (OS), a process may be made up of multiple threads of execution that execute instructions concurrently.[1][2]
While a computer program is a passive collection of instructions, a process is the actual execution of those instructions. Several processes may be associated with the same program; for example, opening up several instances of the same program often results in more than one process being executed.
Roughly how many computer processes are running on your host operating system (Task Manager or Activity Monitor)?
a lot, about 470 when i checked
Why should a full stack Web developer know that computer processes exist?
Because their job is to make processes talk to each other and computer applications are made of multiple processes
You will create a client (browser application) and own server on same computer
What is the process object in a Node.js program?
Process object is global (accessible everywhere without declaring it) and provides information about, and control over, the current Node.js process
How do you access the process object in a Node.js program?
use the process keyword
What is the data type of process.argv in Node.js?
array of strings
What is the JavaScript Event Loop?
Tool for observing when call stack is empty so it can move item from task queue to call stack (JavaScript has a concurrency model based on an event loop, which is responsible for executing the code, collecting and processing events, and executing queued sub-tasks. This model is quite different from models in other languages like C and Java.
What is different between “blocking” and “non-blocking” with respect to how code is executed?
Blocking is when the execution of additional JavaScript in the Node.js process must wait until a non-JavaScript operation completes. This happens because the event loop is unable to continue running JavaScript while a blocking operation is occurring.
Blocking methods execute synchronously and non-blocking methods execute asynchronously.
Blocking code is code executing on the call stack right now and non-blocking is code on the callback queue
What is a JavaScript module?
a javascript file
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, clearInterval
What is the purpose of module.exports in a Node.js module?
to provide functionality to other modules
How do you import functionality into a Node.js module from another Node.js module?
Use require function and pass in path to file
What is a directory?
A folder that lists other files
What is a relative file path?
starts with ./ or leave it off
What is an absolute file path?
The full path from the root of file system
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?
writeFile
Are file operations using the fs module synchronous or asynchronous?
both
writefile sync is blocking so is syncrhnous
whereas writeFile is asynch
What is JSON?
javascript object notation-data interchange format
What are serialization and deserialization and why are they useful?
Serialization is the process of turning an object in memory into a stream of bytes so you can do stuff like store it on disk or send it over the network.
Deserialization is the reverse process: turning a stream of bytes into an object in memory.
Serialization is the process of converting an object into a stream of bytes to store the object or transmit it to memory, a database, or a file. Its main purpose is to save the state of an object in order to be able to recreate it when needed. The reverse process is called deserialization.
How to you serialize data into a JSON string using JavaScript?
JSON.stringify
How do you deserialize a JSON string using JavaScript?
JSON.parse
What is NPM?
Node package manager- npm consists of three distinct components:
• the website
• the Command Line Interface (CLI)
• the registry
What is a package in npm?
A file or directory that is described by a package.json file
How can you create a package.json with npm?
npm init or npm init –yes
What is a dependency and how to you add one to a package?
Something that your application requires and just use npm install
What happens when you add a dependency to a package with npm?
Installs files inside the node_modules folder of your current directory
What is a client?
and service requesters, called clients
What is a server?
providers of a resource or service, called servers,
Which HTTP method does a browser issue to a web server when you visit a URL?
GET
What is the format of an HTTP request message?
Starting line with method and target, headers, and body
What is the format of an HTTP response message?
Status line, headers, and body
How do you add express to your package dependencies?
npm installing it
What Express application method binds the server to a network PORT?
.listen
How do you register a middleware with an Express application?
Use method and passing in a callback function with two parameters req and res