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

(94 cards)

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
How do you mount a middleware with an Express application?
the .use() method
26
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server
request & response objects
27
What is the appropriate Content-type header for HTTP messages that contain JSON in their bodies?
application/json
28
What does the express.json() middleware do and when would you need it?
parses incoming requests with JSON payloads and is based on body-parser used whenever the content-type header matches the type option
29
What is PostgreSQL and what are some alternative relational databases?
an open-source Relational Database Management System | MySQL, SQL Server by Microsoft, and Oracle by Oracle Corp
30
What are some advantages of learning a relational database?
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
31
What is one way to see if PostgreSQL is running?
sudo service postgresql status sudo service postgresql start sudo service postgresql stop
32
What is a database schema?
a collection of tables that defines how the data in a relational database should be organized organization of data
33
What is a table?
where relational databases store data in relations | a table is a list of rows each having the same set of attributes
34
What is a row?
a single structured data item in a table | collection of values that correspond to the attributes of that table
35
What is SQL and how is it different from languages like JavaScript?
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
36
How do you retrieve specific columns from a database table?
select keyword followed by column in double quotes followed by from keyword and database in double quotes
37
How do you filter rows based on some specific criteria?
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
38
What are the benefits of formatting your SQL?
consistent style and readability
39
What are four comparison operators that can be used in a where clause?
1. = 2. != 3. < 4. >
40
How do you limit the number of rows returned in a result set?
use the limit keyword followed by number (not in quotes)
41
How do you retrieve all columns from a database table?
select followed by * asterisk (not in quotes)
42
How do you control the sort order of a result set?
order by keyword, data you want ordered in quotes, followed by desc for descending or nothing for ascending
43
How do you add a row to a SQL table?
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
What is a tuple?
a list of values
45
How do you add multiple rows to a SQL table at once?
after values keyword add each row within parentheses on separate lines, separated by commas
46
How do you get back the row being inserted into a table without a separate select statement?
use returning *
47
How do you update rows in a database table?
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
Why is it important to include a where clause in your update statements?
without a where keyword it would update every row in the table
49
How do you delete rows from a database table?
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
How do you accidentally delete all rows from a table?
if you dont specify with where it will delete the whole table
51
What is a foreign key?
when a value in a column of one table matches the values of a column in another table
52
How do you join two SQL tables?
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
How do you temporarily rename columns or tables in a SQL statement?
using aliases before the column with a period and the as keyword
54
What are some examples of aggregate functions?
``` max() avg() count() min() sum() every() ```
55
What is the purpose of a group by clause?
allows you to separate rows into groups and perform aggregate functions on those groups of rows
56
What are the three states a Promise can be in?
pending fulfilled rejected
57
How do you handle the fulfillment of a promise?
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
How do you handle the rejection of a Promise?
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
What is Webpack?
``` a tool that lets you bundle your JavaScript applications a module bundler ```
60
How do you add a devDependency to a package?
add --save-dev flag when installing the package through npm | npm install --save-dev webpack
61
What is an NPM script?
terminal commands that let you execute script | placed in package.json under scripts
62
How do you execute Webpack with npm run?
npm run ‘script name’
63
What is React?
a declarative, efficient and flexible JavaScript library for building user interfaces
64
What is a React Element?
element describes what you want to see on the screen | react elements are plain objects
65
How do you mount a React Element to the Dom?
ReactDom.render() first argument is element you want to add second argument is where you want to add it
66
What is Babel?
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
What is a Plug-in?
A software component that adds a specific feature to an existing computer program
68
What is a Webpack loader?
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
How can you make Babel and Webpack work together?
using the Babel Loader: | npm install -D babel-loader @babel/core @babel/preset-env webpack
70
What is JSX?
a syntax extension to JavaScript that produces React Elements
71
Why must the React object be imported when authoring JSX in a module?
because JSX compiles into calls, the React library must always be in scope from your JSX code
72
How can you make webpack and babel work together to convert JSX into valid JavaScript?
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
What is a React Component?
similar to JavaScript functions - they accept arbitrary inputs and return React elements describing what should appear on the screen
74
How do you define a function component in React?
write a JavaScript function (or ES6 class) with a return that creates an element first letter of function named needs to be capitalized
75
How do you mount a component to the DOM?
use the ReactDom.render() method with the component as its first argument and where it will be placed as its second argument
76
What are props in React?
keys to the objects being based to createElement arbitrary inputs similar to function parameters - placeholders for properties of a React element
77
How do you pass props to a component?
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
How do you write JavaScript expressions in JSX?
wrapping them within curly brace
79
How do you create a “class” component in React?
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
How do you access props in a class component?
using this
81
What is the purpose of state in React?
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
How do you pass an event handler to a React Element?
you provide a listener when the element is initially rendered pass your function to the buttons submit handler prop
83
What Array method is commonly used to create a list of React elements?
Array.map( )
84
What is the best value to use as a “key” prop when rendering lists?
IDS based on or from your data
85
What are controlled components?
an input form element whose value is controlled by react
86
What does express.static() return?
middleware function
87
What is the local __dirname variable in a Node.js module?
directory name of the current module | same as the path.dirname() of the __filename
88
What does the join( ) method of Node’s path module do?
joins all given path segments together | uses the platform specific separator as a delimiter, then normalizes the resulting path
89
What does fetch() return?
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
What is the default request method used by fetch()?
GET
91
How do you specify the request method(GET, POST, etc) when calling fetch?
pass the method within the optional init parameter when assigning the return of the fetch method to a variable
92
When does React call a component’s componentDidMount method?
immediately after a component is mounted (inserted into the tree) following the initial render()
93
Name three React.Component lifecycle methods.
``` constructor() render() componentDidMount() componentDidUpdate() componentWillUnmount() ```
94
How do you pass data to a child component?
props with props set in this.state uses the render function and ‘value’ props