Node.js, React, Express, SQL, PostgreSQL Flashcards

1
Q

What is Node.js?

A

an open-source, back-end JavaScript runtime environment that runs on the V8 engine and executes JavaScript code outside a web browser

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

What can Node.js be used for?

A

lets developers use JavaScript to write command line tools and server-side scripting
basically - lets you use javaScript everywhere - not just within the browser

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

What is a REPL?

A

Read-eval-print loop
also termed an interactive toplevel or language shell
a simple interactive computer programming environment that takes single user inputs, executes them, and returns the result to the user
executed piecewise

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

When was Node.js created?

A

May 27, 2009

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

What back end languages have you heard of?

A
java
python
ruby
php
C++
C#
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a computer process?

A

A process that is the 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
7
Q

Roughly how many computer processes are running on your host operating system?

A

521

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

Why should a full stack web developer know that computer processes exist?

A

bc Full Stack Web development is based on making multiple processes work together to form one application

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

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

A

The process object is a global that provides information about, and control over, the current Node.js process.

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

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

A

global - always available to Node.js applications

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

What is the data type of process.argv in Node.js?

A

an array of strings

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

What is a JavaScript Module?

A

a single .js file

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

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

A

module & exports objects
convenience variables: __filename and __dirname
require()

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

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

A

process

global

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

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

A

they tell Node.js which bits of code to export from one file so they can be accessed in another

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

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

A

export it from the module with module.exports or exports and use require() in the module you want to use it in.

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

What is a directory?

A

a collection of files

also known as a ‘folder’

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

What is a relative file path?

A

location that is relative to the current directory

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

What is an absolute file path?

A

full URL or file path from the root to a file

starts with ‘/’

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

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

A

fs module

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

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

A

fs.writeFile

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

Are file operations using the fs module synchronous or asynchronous?

A

asynchronous

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

How do you add express to your package dependencies?

A

npm i express within directory containing json.package

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

What express application method starts the server and binds it to a network port?

A

listen()

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

How do you mount a middleware with an Express application?

A

the .use() method

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

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

A

request & response objects

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

What is the appropriate Content-type header for HTTP messages that contain JSON in their bodies?

A

application/json

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

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

A

parses incoming requests with JSON payloads and is based on body-parser
used whenever the content-type header matches the type option

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

What is PostgreSQL and what are some alternative relational databases?

A

an open-source Relational Database Management System

MySQL, SQL Server by Microsoft, and Oracle by Oracle Corp

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

What are some advantages of learning a relational database?

A

they are the most widely used kind of database
support good guarantees about data integrity
most web developers work with a relational database at least a little bit during their career

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

What is one way to see if PostgreSQL is running?

A

sudo service postgresql status
sudo service postgresql start
sudo service postgresql stop

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

What is a database schema?

A

a collection of tables that defines how the data in a relational database should be organized
organization of data

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

What is a table?

A

where relational databases store data in relations

a table is a list of rows each having the same set of attributes

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

What is a row?

A

a single structured data item in a table

collection of values that correspond to the attributes of that table

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

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

A

Structured Query Language
a domain specific language used in programming and designed for managing data held in a relational database management system or for stream processing in a relational data stream management system
useful in handling structured data
SQL is declarative not imperative

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

How do you retrieve specific columns from a database table?

A

select keyword followed by column in double quotes followed by from keyword and database in double quotes

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

How do you filter rows based on some specific criteria?

A

use the “where” keyword followed by where you want to grab data from, the operator and the data you want in single quotes
where needs to evaluate to true or false

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

What are the benefits of formatting your SQL?

A

consistent style and readability

39
Q

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

A
  1. =
  2. !=
  3. <
  4. >
40
Q

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

A

use the limit keyword followed by number (not in quotes)

41
Q

How do you retrieve all columns from a database table?

A

select followed by * asterisk (not in quotes)

42
Q

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

A

order by keyword, data you want ordered in quotes, followed by desc for descending or nothing for ascending

43
Q

How do you add a row to a SQL table?

A

use the insert into keyword followed by the table you want data inserted into
followed by the column names in double quotes separated by commas in parentheses
on next line, values keyword followed by data you want inserted in same order as columns, in single quotes separated by commas

44
Q

What is a tuple?

A

a list of values

45
Q

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

A

after values keyword add each row within parentheses on separate lines, separated by commas

46
Q

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

A

use returning *

47
Q

How do you update rows in a database table?

A

update keyword followed by table you want updated in ()
next line: set keyword followed by column you want to change, equals sign and value you want it changed to
next line: where keyword followed by column/row pair that signifies row you want changed

48
Q

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

A

without a where keyword it would update every row in the table

49
Q

How do you delete rows from a database table?

A

use delete from keywords followed by the table you want to delete from
next line: use where keyword to identify which piece of data you want to delete

50
Q

How do you accidentally delete all rows from a table?

A

if you dont specify with where it will delete the whole table

51
Q

What is a foreign key?

A

when a value in a column of one table matches the values of a column in another table

52
Q

How do you join two SQL tables?

A

select what you want from the table you want and use the join keyword followed by the table to be joined followed by the using keyword followed by the foreign key in parentheses

53
Q

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

A

using aliases before the column with a period and the as keyword

54
Q

What are some examples of aggregate functions?

A
max()
avg()
count()
min()
sum()
every()
55
Q

What is the purpose of a group by clause?

A

allows you to separate rows into groups and perform aggregate functions on those groups of rows

56
Q

What are the three states a Promise can be in?

A

pending
fulfilled
rejected

57
Q

How do you handle the fulfillment of a promise?

A

call .then() method of the promise object with a callback function to handle success
calls a function if promise is fulfilled with one argument - the fulfillment value
the promise is given the value of the return

58
Q

How do you handle the rejection of a Promise?

A

call .catch() method of the promise object with a callback function to handle error
calls a function when promise is rejected
throws an error (reason)

59
Q

What is Webpack?

A
a tool that lets you bundle your JavaScript applications
a module bundler
60
Q

How do you add a devDependency to a package?

A

add –save-dev flag when installing the package through npm

npm install –save-dev webpack

61
Q

What is an NPM script?

A

terminal commands that let you execute script

placed in package.json under scripts

62
Q

How do you execute Webpack with npm run?

A

npm run ‘script name’

63
Q

What is React?

A

a declarative, efficient and flexible JavaScript library for building user interfaces

64
Q

What is a React Element?

A

element describes what you want to see on the screen

react elements are plain objects

65
Q

How do you mount a React Element to the Dom?

A

ReactDom.render()
first argument is element you want to add
second argument is where you want to add it

66
Q

What is Babel?

A

A JavaScript compiler that is mainly used to convert ECMAScript 2015 code into backwards compatible version of JavaScript in current and older browsers or environments

67
Q

What is a Plug-in?

A

A software component that adds a specific feature to an existing computer program

68
Q

What is a Webpack loader?

A

transformations that are applied to the source code of a module that allow you to pre-process files as you import or ‘load’ them

69
Q

How can you make Babel and Webpack work together?

A

using the Babel Loader:

npm install -D babel-loader @babel/core @babel/preset-env webpack

70
Q

What is JSX?

A

a syntax extension to JavaScript that produces React Elements

71
Q

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

A

because JSX compiles into calls, the React library must always be in scope from your JSX code

72
Q

How can you make webpack and babel work together to convert JSX into valid JavaScript?

A

babel compiles JSX down to React.createElement() calls
webpack runs the babel + JSX + react
the babel transform plugin is loaded into the webpack.config.js file
@babel/plugin-transform-react-jsx is added to the babel-loader within webpack

73
Q

What is a React Component?

A

similar to JavaScript functions - they accept arbitrary inputs and return React elements describing what should appear on the screen

74
Q

How do you define a function component in React?

A

write a JavaScript function (or ES6 class) with a return that creates an element
first letter of function named needs to be capitalized

75
Q

How do you mount a component to the DOM?

A

use the ReactDom.render() method with the component as its first argument and where it will be placed as its second argument

76
Q

What are props in React?

A

keys to the objects being based to createElement
arbitrary inputs
similar to function parameters - placeholders for properties of a React element

77
Q

How do you pass props to a component?

A

use a key= pair when using the Component
use props as the parameter for the React Component
surrounding it with { } within Component declaration code-block

78
Q

How do you write JavaScript expressions in JSX?

A

wrapping them within curly brace

79
Q

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

A

create an ES6 class that extends React.Component
Add a single empty method to it called render()
Move the body of the function into the render() method
Replace props with this.props in the render() body
Delete the remaining empty function declaration

80
Q

How do you access props in a class component?

A

using this

81
Q

What is the purpose of state in React?

A

an object that determine how a component renders and behaves
the state object is where you store property values the belong to the component - when the state object changes, the component re-renders

82
Q

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

A

you provide a listener when the element is initially rendered
pass your function to the buttons submit handler prop

83
Q

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

A

Array.map( )

84
Q

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

A

IDS based on or from your data

85
Q

What are controlled components?

A

an input form element whose value is controlled by react

86
Q

What does express.static() return?

A

middleware function

87
Q

What is the local __dirname variable in a Node.js module?

A

directory name of the current module

same as the path.dirname() of the __filename

88
Q

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

A

joins all given path segments together

uses the platform specific separator as a delimiter, then normalizes the resulting path

89
Q

What does fetch() return?

A

a promise that resolves to a Response object

promise object represents the eventual completion or failure of an asynchronous operation and its resulting value

90
Q

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

A

GET

91
Q

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

A

pass the method within the optional init parameter when assigning the return of the fetch method to a variable

92
Q

When does React call a component’s componentDidMount method?

A

immediately after a component is mounted (inserted into the tree) following the initial render()

93
Q

Name three React.Component lifecycle methods.

A
constructor()
render()
componentDidMount()
componentDidUpdate()
componentWillUnmount()
94
Q

How do you pass data to a child component?

A

props
with props set in this.state
uses the render function and ‘value’ props