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
Q

What is a server?

A

-a computer program or device that provides a resource or service to a client

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

Which HTTP method does a browser issue to a web server when you visit a URL?

A

GET method

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

What is the format of an HTTP request message? (Review contents of flash card- July 7)

A
  1. Start-line (protocol version, status, status text)
  2. headers
  3. body (optional)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
28
Q

What is the format of an HTTP response message?

A
  1. status line(protocol version, status, status text)
  2. headers
  3. body (optional)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
29
Q

What is a computer process?

A

-an instance of a computer program that is being executed by one or many threads

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

How do you add express to your package dependencies?

A

npm init -y, then npm install express.

once you create a new package.json, you can include it in the dependancy

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

What Express application method binds the server to a network PORT?

A

app. listen();

- use require to pull in whatever the express package exports

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

what is a middleware function?

A

-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

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

How do you register a middleware with an Express application?

A

-call the use method, and pass in a callback as an argument

Example: app.use(callback-method here)

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

Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?

A

request object, and the response object

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

what does root: __dirname do?

A

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

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

What is the content-type header of HTTP requests and responses used for?

A

to indicate the media type of the resource

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

What does express.static() return?

A

It returns a new middleware function

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

What is the local__dirname variable in a Node.js module?

A

the directory the file itself is in

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

What does the join() method of Node’s path module do?

A

it combines all specified path segments together

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

What is the appropriate Content-Type header for requests and responses that contain JSON in their bodies?

A

-application/ json

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

What does the express.json() middleware do and when would you need it?

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
42
Q

What is the significance of an HTTP request’s method?

A

the method tells the server what the client is trying to do

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

What is Node.js?

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
44
Q

What can Node.js be used for?

A

-it is used to build scalable network applications

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

What is a REPL?

A

Read-eval-print-loop

-Interactive programming environment

46
Q

What is Webpack?

A

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
Q

How do you add a devDependency to a package?

A

npm install –save-dev (or -D)

48
Q

What is an NPM script?

A
  • 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
Q

How do you execute Webpack with npm run?

A

npm run build

50
Q

What is an ES6 module and how is it different from CommonJS module?

A
  • 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
Q

What kind of modules can Webpack support?

A
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
Q

What is the virtual DOM?

A
  • 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
Q

What is a react element?

A

A react element is an object that describes what the DOM should look like

54
Q

What is React?

A

React is a JS framework (some argue it is a library) for building interactive user interfaces

55
Q

What is a React Element?

A

It is an object

56
Q

How do you mount a React element to the DOM?

A

Call the render method of the ReactDOM object

57
Q

What is Babel?

A
  • 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
Q

What is a Plug-In?

A

-it’s a software component that adds a specific feature to an existing computer program

59
Q

What is a Webpack loader?

A
  • 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
Q

How can you make Babel and Webpack work together?

A

You have to install the babel loader which will allow you to use babel and webpack together

61
Q

What is JSX?

A

-it’s a syntax extension to JavaScript, basically a combination of JavaScript and HTML, leaning more towards the JavaScript side

62
Q

Why must the React object be imported when authoring JSX in a module?

A
  • the react library has to be in the scope of the JSX

- JSX tags compile into function calls of react.createElement()

63
Q

How can you make Webpack and Babel work together to convert JSX into valid JavaScript?

A

You need a babel loader with the plugin-transform-react-jsx

64
Q

What is a React component?

A
  • they are JavaScript functions, and they accept inputs called props
  • it returns React Elements
65
Q

How do you define a function component in React?

A

-function keyword, and a capital first letter for the name of your component

66
Q

How do you mount a component to the DOM?

A

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
Q

What are controlled components and how do you work with them?

A
  • 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
Q

What are the three states a Promise can be in?

A
  • pending: initial state, neither fulfilled nor rejected
  • fulfilled: meaning that the operation completed successfully
  • rejected: meaning the operation failed
69
Q

How do you handle the fulfillment of a Promise?

A

can use promise.then() , and then pass a callback function to handle the fulfillment

70
Q

How do you handle the rejection of a Promise?

A

can use the then method, or the catch method (catch method is preferable)
(for example:
promise.then
promise.catch)

71
Q

What does fetch() return?

A

it returns a promise that resolves to a response object

72
Q

What is the default request method used by fetch()?

A

GET

73
Q

How do you specify the request method (GET,POST, etc.) when calling fetch?

A

You can create an optional init object containing the method setting (GET, POST, etc)

74
Q

When does React call a component’s componentDidMount method?

A

-immediately after a component is mounted(inserted into the tree)

75
Q

Name three React.Component lifecycle methods.

A

Constructor(), render(), ComponentDidMount(), setState()

76
Q

How do you pass data to a child component?

A

As a prop

77
Q

What is PostgreSQL?

A

-it is an open source Relational Database Management System

78
Q

What are some alternative relational databases?

A

MySQL, SQL Server, Oracle

79
Q

What are some advantages of learning a relational database?

A

They can guarantee data integrity, and they can store and modify data in a way that makes data corruption as unlikely as possible

80
Q

How do you check if PostgreSQL is running?

A
  • you can use the top command in the CLI

- sudo service postgresql status

81
Q

What is a database schema?

A
  • a collection of tables

- a schema defines how the data in a relational database should be organized

82
Q

What is a table?

A
  • 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
Q

What is a row?

A
  • data that pertains to the attributes, each row in the table has the same structure
  • a homogeneous set of attributes
84
Q

What is SQL and how is it different from languages like JavaScript?

A
  • 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
Q

How do you retrieve specific columns from a database table?

A

SELECT keyword, and the FROM clause specifying which table to retrieve the data from

86
Q

How do you filter rows based on some specific criteria?

A
  • WHERE clause

- it is the predicate (when you try to say if something is true or not)

87
Q

What are the benefits of formatting your SQL?

A

-it is easier to read, understand, and manipulate

88
Q

What are four comparison operators that can be used in a WHERE clause?

A

= , < , > , !=

89
Q

How do you limit the number of rows returned in a result set?

A

LIMIT clause

90
Q

How do you retrieve all columns from a database table?

A

SELECT *

91
Q

How do you control the sort order of a result set?

A

ORDER BY clause

92
Q

How do you add a row to a SQL table?

A
  • use the INSERT INTO clause

- then the VALUES clause to specify the values for the columns you inserted in

93
Q

What is a tuple?

A

-a list of values (use parentheses around the list)

94
Q

How do you add multiple rows to a SQL table at once?

A

you can specify more than one tuple of VALUES, separated by commas

95
Q

How do you get back the row being inserted into a table without a separate select statement?

A
  • use the RETURNING statement

- if you want specific values, you can use a comma-separated list of column names instead

96
Q

How do you update rows in a database table?

A

-use the UPDATE statement, and SET clause, and use WHERE clause to target what you want to update

97
Q

Why is it important to include a where clause in your update statements?

A

-you want to be very specific with what you update, or else it might update the whole table

98
Q

How do you delete rows from a database table?

A

DELETE FROM statement, with a WHERE clause to specify what you want to delete

99
Q

How do you accidentally delete all rows from a table?

A

DELETE FROM clause with no WHERE statement to specify what you want to delete

100
Q

What are props in React?

A
  • arbitrary inputs (called props)
  • you can pass any JavaScript expression as a prop, by surrounding it with {}
  • they are objects you pass in
101
Q

How do you pass props to a component?

A

-you wrap it with curly braces, or surround it with quotes if it is a string

102
Q

What array method is commonly used to create a list of React elements?

A

array.map();

103
Q

What is the best value to use as a “key” prop when rendering lists?

A

-a string that uniquely identifies a list item among its siblings

104
Q

How do you create a “class” component in React?

A
  • you need to use the class keyword and the extends React.Component
  • also needs a render function
105
Q

How do you access props in a class component?

A

-use the “this” keyword (this.props.text)

106
Q

What is the purpose of state in React?

A

-to keep track of things that change over time

107
Q

How do you pass an event handler to a React element?

A

-you pass it as a prop

108
Q

What is a foreign key?

A
  • an attribute that links to another table
  • the column value has to be the same
  • the value in a column
109
Q

How do you join two SQL tables?

A
  • join statement, and the using keyword (‘specify attribute here’)
  • else specify which columns you are using with the on keyword
110
Q

How do you temporarily rename columns or names in a SQL statement?

A

-use the as keyword (an alias)

111
Q

What are some examples of aggregate functions?

A

min, max, sum, avg, count

112
Q

What is the purpose of a group by clause?

A

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