Nightly Review Flashcards

1
Q

What is Array.prototype.filter for?

A

-creates a new array with all elements that pass the condition or test you specify

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is Array.prototype.map useful for?

A
  • Allows you to quickly iterate and manipulate values of an array
  • for example, double every element in the array
  • creates a new array as well
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the process object in a Node.js program?

A
  • it’s a global that provides information about, and control over the current node.js processes
  • it is always available to node.js applications without using require
  • global means it is available in any files, without having to declare it
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How do you access the process object in a Node.js program?

A
  • you can explicitly access it using require(‘process);

- b/c it is a global, it is always available w/out require

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the datatype of process.argv in Node.js?

A
  • returns an array of strings

- it contains the command line arguments passed when the node.js process was launched

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the JavaScript Event Loop?

A
  • it is a “handler”
  • it looks at the stack and the task queue, and if the stack is empty it takes the first thing on the queue and pushes it onto the stack
  • it allows JavaScript to run tasks concurrently
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the difference between “blocking” and “non-blocking” with respect to how code is executed?

A
  • blocking code is code that runs within the stack

- non-blocking code is code that is put into the callback queue

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a JavaScript module?

A
  • a module is a single JS file

- each file in node.js is treated as a separate module

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What values are passed into a Node.js module’s local scope?

A

-exports, require, module, __filename, and __dirname

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Give two examples of truly global variables in a Node.js program

A

-global, process, setTimeOut, setInterval, Buffer

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the purpose of module.exports in a Node.js module?

A

-to use functions, objects, or arrays in other modules

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you import functionality into a Node.js module from another Node.js module?

A

-require function, and then the path of the file

require(‘./filename’);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a directory?

A

-a file that lists other files

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a relative file path?

A
  • it’s the path towards your file from wherever you are

- starts with ./ (or can leave it off, the ./ is implied)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is an absolute file path?

A

The full path, starting at the root of your system

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What module does Node.js include for manipulating the file system?

A

the file system module

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

What method is available in the Node.js fs module for writing data to a file?

A

writeFile method

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Are file operations using the fs module synchronous or asynchronous?

A

both!
writeFile is async,
writeFileSync is sync

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What is JSON?

A
  • it is a string

- text based data following javascript object syntax

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is serialization and why is it useful?

A
  • serialization: converting a native object to a string so it can be transmitted across the network
  • the process of turning an object in memory into a stream of bytes so you can store it on a disk or send it over a network
  • allows you to convert your data into JSON and communicate with servers
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

What is deserialization and why is it useful?

A
  • deserialization: converting a string to a native object

- the reverse: turning a stream of bytes into an object in memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

How do you serialize data into a JSON string using JavaScript?

A

JSON.stringify()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

How do you deserialize a JSON string using JavaScript?

A

JSON.parse()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

What is a client?

A
  • a computer or software that accesses a service made available by a server
  • something that sends a request
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What is a server?
-a computer program or device that provides a resource or service to a client
26
Which HTTP method does a browser issue to a web server when you visit a URL?
GET method
27
What is the format of an HTTP request message? (Review contents of flash card- July 7)
1. Start-line (protocol version, status, status text) 2. headers 3. body (optional)
28
What is the format of an HTTP response message?
1. status line(protocol version, status, status text) 2. headers 3. body (optional)
29
What is a computer process?
-an instance of a computer program that is being executed by one or many threads
30
How do you add express to your package dependencies?
npm init -y, then npm install express. | once you create a new package.json, you can include it in the dependancy
31
What Express application method binds the server to a network PORT?
app. listen(); | - use require to pull in whatever the express package exports
32
what is a middleware function?
-functions that have access to the request object(req), the response object(res), and the next (next parameter) middleware function in the application's request response cycle
33
How do you register a middleware with an Express application?
-call the use method, and pass in a callback as an argument | Example: app.use(callback-method here)
34
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
request object, and the response object
35
what does root: __dirname do?
it's part of the options argument, and you can use it to check to see the relative directory instead of from the absolute file path
36
What is the content-type header of HTTP requests and responses used for?
to indicate the media type of the resource
37
What does express.static() return?
It returns a new middleware function
38
What is the local__dirname variable in a Node.js module?
the directory the file itself is in
39
What does the join() method of Node's path module do?
it combines all specified path segments together
40
What is the appropriate Content-Type header for requests and responses that contain JSON in their bodies?
-application/ json
41
What does the express.json() middleware do and when would you need it?
- it parses the body of your request, and recognizes it as a json object - if your server needs to receive JSON from a client, then you need to express.json() to work
42
What is the significance of an HTTP request's method?
the method tells the server what the client is trying to do
43
What is Node.js?
- It's a program that lets you run javascript outside of a web browser - it lets you build back ends for web applications, command-line programs, or any kind of automation - it is powered by v8; the same JavaScript engine in the google chrome browser
44
What can Node.js be used for?
-it is used to build scalable network applications
45
What is a REPL?
Read-eval-print-loop | -Interactive programming environment
46
What is Webpack?
It's a tool that lets you bundle your JS applications (supporting both ESM and CommonJS), and it can be extended to support many different assets such as images, fonts, and stylesheets
47
How do you add a devDependency to a package?
npm install --save-dev (or -D)
48
What is an NPM script?
- specify it in a package.json - something that you can run from the terminal, that does a specific task - a command line command embedded in a package.json(a shortcut)
49
How do you execute Webpack with npm run?
npm run build
50
What is an ES6 module and how is it different from CommonJS module?
- it creates a format that both users of commonJS and AMD can be happy with - ES6 modules have import, and export keywords, while CommonJS has require, and export.module - browsers can use ES6 modules, but CommonJS modules don't work by default
51
What kind of modules can Webpack support?
``` absolute paths, relative paths, and module paths - can support a ton of different module types : coffeescript, commonjs, and es6 modules out of the box ```
52
What is the virtual DOM?
- it is how react uses plain JavaScript objects to describe the real DOM - the react element objects and how react compares them to each other
53
What is a react element?
A react element is an object that describes what the DOM should look like
54
What is React?
React is a JS framework (some argue it is a library) for building interactive user interfaces
55
What is a React Element?
It is an object
56
How do you mount a React element to the DOM?
Call the render method of the ReactDOM object
57
What is Babel?
- Babel is a JS compiler | - it converts ES6 (ES2015) code into a backwards compatible version of JS in current and older browser or environments
58
What is a Plug-In?
-it's a software component that adds a specific feature to an existing computer program
59
What is a Webpack loader?
- loaders are transformations that are applied to the source code of a module - they allow you to preprocess filesas you import or "load" them
60
How can you make Babel and Webpack work together?
You have to install the babel loader which will allow you to use babel and webpack together
61
What is JSX?
-it's a syntax extension to JavaScript, basically a combination of JavaScript and HTML, leaning more towards the JavaScript side
62
Why must the React object be imported when authoring JSX in a module?
- the react library has to be in the scope of the JSX | - JSX tags compile into function calls of react.createElement()
63
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
You need a babel loader with the plugin-transform-react-jsx
64
What is a React component?
- they are JavaScript functions, and they accept inputs called props - it returns React Elements
65
How do you define a function component in React?
-function keyword, and a capital first letter for the name of your component
66
How do you mount a component to the DOM?
You create a React element, and then pass it to the first argument of the render method of the React DOM object (ReactDOM.render()
67
What are controlled components and how do you work with them?
- An input form element whose value is controlled by React | - a controlled component has it's value passed to it from state, and it has a change event handler
68
What are the three states a Promise can be in?
- pending: initial state, neither fulfilled nor rejected - fulfilled: meaning that the operation completed successfully - rejected: meaning the operation failed
69
How do you handle the fulfillment of a Promise?
can use promise.then() , and then pass a callback function to handle the fulfillment
70
How do you handle the rejection of a Promise?
can use the then method, or the catch method (catch method is preferable) (for example: promise.then promise.catch)
71
What does fetch() return?
it returns a promise that resolves to a response object
72
What is the default request method used by fetch()?
GET
73
How do you specify the request method (GET,POST, etc.) when calling fetch?
You can create an optional init object containing the method setting (GET, POST, etc)
74
When does React call a component's componentDidMount method?
-immediately after a component is mounted(inserted into the tree)
75
Name three React.Component lifecycle methods.
Constructor(), render(), ComponentDidMount(), setState()
76
How do you pass data to a child component?
As a prop
77
What is PostgreSQL?
-it is an open source Relational Database Management System
78
What are some alternative relational databases?
MySQL, SQL Server, Oracle
79
What are some advantages of learning a relational database?
They can guarantee data integrity, and they can store and modify data in a way that makes data corruption as unlikely as possible
80
How do you check if PostgreSQL is running?
- you can use the top command in the CLI | - sudo service postgresql status
81
What is a database schema?
- a collection of tables | - a schema defines how the data in a relational database should be organized
82
What is a table?
- a table is a relation | - a table is a list of rows each having the same set of attributes (attributes are commonly referred to as columns)
83
What is a row?
- data that pertains to the attributes, each row in the table has the same structure - a homogeneous set of attributes
84
What is SQL and how is it different from languages like JavaScript?
- SQL is a Structured Query Language, and it is the primary way of interacting with relational databases. - unlike JavaScript, SQL is a declarative programming language. Relational databases interpret SQL and then dynamically generate a plan of action to perform the programmer's commands as efficiently as possible
85
How do you retrieve specific columns from a database table?
SELECT keyword, and the FROM clause specifying which table to retrieve the data from
86
How do you filter rows based on some specific criteria?
- WHERE clause | - it is the predicate (when you try to say if something is true or not)
87
What are the benefits of formatting your SQL?
-it is easier to read, understand, and manipulate
88
What are four comparison operators that can be used in a WHERE clause?
= , < , > , !=
89
How do you limit the number of rows returned in a result set?
LIMIT clause
90
How do you retrieve all columns from a database table?
SELECT *
91
How do you control the sort order of a result set?
ORDER BY clause
92
How do you add a row to a SQL table?
- use the INSERT INTO clause | - then the VALUES clause to specify the values for the columns you inserted in
93
What is a tuple?
-a list of values (use parentheses around the list)
94
How do you add multiple rows to a SQL table at once?
you can specify more than one tuple of VALUES, separated by commas
95
How do you get back the row being inserted into a table without a separate select statement?
- use the RETURNING statement | - if you want specific values, you can use a comma-separated list of column names instead
96
How do you update rows in a database table?
-use the UPDATE statement, and SET clause, and use WHERE clause to target what you want to update
97
Why is it important to include a where clause in your update statements?
-you want to be very specific with what you update, or else it might update the whole table
98
How do you delete rows from a database table?
DELETE FROM statement, with a WHERE clause to specify what you want to delete
99
How do you accidentally delete all rows from a table?
DELETE FROM clause with no WHERE statement to specify what you want to delete
100
What are props in React?
- arbitrary inputs (called props) - you can pass any JavaScript expression as a prop, by surrounding it with {} - they are objects you pass in
101
How do you pass props to a component?
-you wrap it with curly braces, or surround it with quotes if it is a string
102
What array method is commonly used to create a list of React elements?
array.map();
103
What is the best value to use as a "key" prop when rendering lists?
-a string that uniquely identifies a list item among its siblings
104
How do you create a "class" component in React?
- you need to use the class keyword and the extends React.Component - also needs a render function
105
How do you access props in a class component?
-use the "this" keyword (this.props.text)
106
What is the purpose of state in React?
-to keep track of things that change over time
107
How do you pass an event handler to a React element?
-you pass it as a prop
108
What is a foreign key?
- an attribute that links to another table - the column value has to be the same - the value in a column
109
How do you join two SQL tables?
- join statement, and the using keyword ('specify attribute here') - else specify which columns you are using with the on keyword
110
How do you temporarily rename columns or names in a SQL statement?
-use the as keyword (an alias)
111
What are some examples of aggregate functions?
min, max, sum, avg, count
112
What is the purpose of a group by clause?
group by clause groups by rows (it slices up the result set into chunks of rows, and then operates on those groups) -if you want to separate rows into groups and perform aggregate functions on those groups of rows