Misc Flashcards
What is a CLI?
-command-line interface (Bash, Cmder)
What is a GUI?
-graphical user interface (VS Code, MS Windows/Mac displays)
Give at least one use case for this command:
-man
-man man (prints the manual for manual)
Give at least one use case for this command:
-cat
-cat three-virtues.txt (prints the txt from the txt file)
Give at least one use case for this command:
-ls
-ls (prints the contents of current directory)
Give at least one use case for this command:
-pwd
-pwd (prints the address of your current working directory)
Give at least one use case for this command:
-echo
-echo ‘Hello, World!’ > hello.txt (inserts ‘Hello, World!’ into hello.txt file)
Give at least one use case for this command:
-touch
-touch new-file.txt (creates a new file and updates its timestamp)
Give at least one use case for this command:
-mkdir
-mkdir parent (creates a new directory)
Give at least one use case for this command:
-mv
-mv pokiemans pokemon (renames pokiemans directory to pokemon)
Give at least one use case for this command:
-rm
-rm extraneous.txt (removes extraenous.txt)
Give at least one use case for this command:
-cp
-cp original.txt copyOf.txt (makes a copyOf.txt file from original.txt)
What are some back end languages?
-JavaScript, Python, PHP, Java, Ruby, C, C#, C++, Rust, Perl, Swift, Go
What makes JavaScript unique?
-prototypal inheritance, “this”, event loops, closure
What is a computer process?
-an instance of a computer program that is being executed
What is NPM?
- node package manager
- a software registry where developers can share and borrow packages
- has: website, registry, CLI
What is a package?
- aka a “module”, containing bits of reusable code
- exists as a directory with package + package.json + other files
How can you create a package.json with npm?
- navigate to the root directory of your package
2. “npm init -y” (default package.json) or “npm init” (manually answer prompts)
What is package.json?
- lists the packages your project depends on
- specifies versions of a package that your project can use
- makes your build reproducible, and therefore easier to share with other developers
What is a dependency and how to you add one to a package?
- a package that your package needs in order to work
- add new dependencies by installing them in the root directory of your package “npm install” and adding “–save”
What happens when you add a dependency to a package with npm?
- allows the project to install the versions of the modules it depends on
- by running “npm install”, you can install all of the dependencies that are listed in the project’s package.json
What does “npm init” do?
“npm init” is a command to scaffold out your project
“npm init –yes” will instantly initialize a project with default values
What is on the first line of an HTTP response message?
- The protocol version, usually HTTP/1.1
- A status code, indicating success or failure of the request (200, 404, 302…)
- A status text. A brief, human-readable, informational text about the status code
What is on the first line of an HTTP request message?
- HTTP method (POST, GET, PUT, HEAD, OPTIONS, etc)
- request target (URL)
- HTTP version
What is express js?
-a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications
How do you add express to your package dependencies?
npm install express in your root directory or manually edit package.json
What Express application method starts the server and binds it to a network PORT?
listen()
What is the difference between the internet and the web?
internet: network of computers
web: the links between documents (messaging format called HTTP)
How do you mount a middleware with an Express application?
app.use()
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
req, res
What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?
application/json
What does the express.json() middleware do and when would you need it?
- express.json() is a built-in function in Express that parses incoming requests with JSON payloads
- you would need this when you want to parse JSON request bodies
What is the significance of an HTTP request’s method?
-indicates what type of request is being made to the web server, and the corresponding action that will be performed on whatever resource you’re accessing
What do the following HTTP verbs do?
- POST
- GET
- PUT
- DELETE
POST: creates
GET: reads
PUT: updates
DELETE: deletes
What is “syntactic sugar”?
-syntax that makes things easier for humans to read or express
What is “refactoring”?
-restructuring code while preserving its existing functionality
What is Webpack?
a tool that lets you bundle your JavaScript applications (bundles all your modules into one)
How do you add a devDependency to a package?
–save-dev when you npm install
What is an NPM script?
An npm script that bundles common shell commands for your project
How do you execute Webpack with npm run?
-by adding a script that runs Webpack into “scripts” in package.json
How are ES Modules different from CommonJS modules?
- syntax is different:
- ES6: import/export
- CommonJS: require/module.exports
- CommonJS modules load dependencies on demand while executing the code
- ES6 modules are pre-parsed in order to resolve further imports before code is executed
What kind of modules can Webpack support?
ES6, CommonJS, AMD modules
What is Babel?
Babel is a JavaScript compiler mainly used to convert ES6 code into a backwards compatible version of JavaScript
What is a Plug-in?
a software component that adds a specific feature to an existing computer program
What is a Webpack loader?
Loaders are transformations that are applied to the source code of a module
How can you make Babel and Webpack work together?
install ‘babel-loader’ and include loader: ‘babel-loader’ in package.json
@@@ my answer… @@@
1) in package.json, add a script that will build the app using Webpack+Babel:
“scripts”: {
“build”: “webpack”}
2) npm run build
3) modify in index.html to load the compiled version:
What does express.static() return?
- express.static() is a built-in middleware function that serves static files
- returns an object that has the requested static files
What is the local __dirname variable in a Node.js module?
-tells you the absolute path of the directory containing the currently executing file
What does the join() method of Node’s path module do?
path.join() joins all given path segments together into one path
What does fetch() return?
Calling fetch() returns a promise. We can then wait for the promise to resolve by passing a handler with the then() method of the promise. That handler receives the return value of the fetch promise, a Response object
What is the default request method used by fetch()?
GET
How do you specify the request method (GET, POST, etc.) when calling fetch?
put the request method after the resource url, as part of the optional fetch() parameters
syntax:
fetch(url, [options])
example:
fetch(url, {method: ‘POST’})
.then(response => response.json())
.then(data => console.log(data));
When does React call a component’s componentDidMount method?
after first successful render to the DOM. constructor and render must run successfully
Name three React.Component lifecycle methods.
constructor(), render(), componentDidMount(), componentDidUpdate(), componentWillUnmount()
How do you pass data to a child component?
through the props
What must the return value of myFunction be if the following expression is possible?
myFunction()();
must return the inner (nested) function of the first function. calling a function n immediately calling its return value
What does this code do? const wrap = value => () => value;
assigns a function “value” to const wrap. this function has an anonymous function that returns something as well
In JavaScript, when is a function’s scope determined; when it is called or when it is defined?
when it’s defined.. double check
What allows JavaScript functions to “remember” values from their surroundings?
closure (you can check this by console.dir and opening up the 3 scopes. it will be in the closure scope)
What are “props” in React?
props is a keyword in React that stands for "properties" and is used for passing data from one component to another this.props contains the props defined by the caller of the component props are read-only. this is how the concept of "states" developed: to allow the changing of the React state without changing the props. we use class components when we are expecting features like managing state, adding life cycles, n event handlers.
What does the acronym LIFO mean?
the last thing pushed onto the stack is the first thing that can be popped out
What methods are available on a Stack data structure?
- push()
- pop()
- peek()
What must you do to access the value at an arbitrary point in a stack (not just the “top”)?
you have to keep using pop() to peel away enough layers to reach the particular point in the stack
What does the acronym FIFO mean?
the first thing enqueued onto the queue is the first thing that can be dequeued out
What methods are available on a Queue data structure?
enqueue(value) - adds a value to the “back” of the queue
dequeue() - removes the “front” value from the queue and returns it
What must you do to access the value at an arbitrary point in a queue (not just the “front”)?
keep using dequeue() to “peel away” to that particular point in a queue
How are linked lists different from an array?
linked lists “point” to the next node
How would you access an arbitrary node in a linked list (not just the “head”)?
keep looking at the .next node (.next.next.next)