Backend Flashcards

1
Q

Es-6-const-let

What is a code block? What are some examples of a code block?

A

Code blocks are denoted by curly braces. Examples are if else, for, do while, while, try catch and so on.

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

Es-6-const-let

What does block scope mean?

A

A block scoped variable means that the variable defined within a block will not be accessible from outside the block. A block can reside inside a function, and a block scoped variable will not be available outside the block even if the block is inside a function.

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

Es-6-const-let

What is the scope of a variable declared with const or let?

A

Block-scope

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

Es-6-const-let

What is the difference between let and const?

A

The const keyword cannot be reassigned, meaning it creates a read-only reference to a value. But the let keyword is mutable, meaning you can change its values anytime.

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

Es-6-const-let

Why is it possible to .push() a new value into a const variable that points to an Array?

A

We are not reassigning the value of a variable.

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

Es-6-const-let

How should you decide on which type of declaration to use?

A

If you don’t intend to modify the variable, then use the const keyword. Otherwise, use let keyword. Always default const if you are not sure.

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

Es-6-template-literals

What is the syntax for writing a template literal?

A

Keyword variable name equal sign backticks with text content.

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

Es-6-template-literals

What is “string interpolation”?

A

String interpolation is replacing placeholders with values in a string literal.

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

Es-6-destructuring

What is destructuring, conceptually?

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

Es-6-destructuring

What is the syntax for Object destructuring?

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

Es-6-destructuring

What is the syntax for Array destructuring?

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

Es-6-destructuring

How can you tell the difference between destructuring and creating Object/Array literals?

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

Es-6-arrow-functions

What is the syntax for defining an arrow function?

A
Variable keyword, function name, equal sign, parameters with parenthesis, arrow, function code block with curly braces if there is more than one line
let add = (x, y) => x + y;
let add = (x, y) => {return x + y};
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Es-6-arrow-functions

When an arrow function’s body is left without curly braces, what changes in its functionality?

A

Implicitly return value

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

Es-6-arrow-functions

How is the value of this determined within an arrow function?

A

Refers to window object or global object
Arrow functions do not have their own this.
Whatever this is in the parent scope and it doesn’t create own lexical scope

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

Command-line-basics

What is a CLI?

A

Command-line interface
A command-line interpreter or command-line processor uses a CLI to receive commands from a user in the form of lines of text. This provides a means of setting parameters for the environment, invoking executables and providing information to them as to what actions they are to perform.

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

Command-line-basics

What is a GUI?

A

Graphical user Interface.
A GUI is a form of user interface that allows users to interact with electronic devices through graphical icons and audio indicators such as primary notation, instead of text-based UIs, typed command labels or text navigation.

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

Command-line-basics

Give at least one use case for each of the commands listed in this exercise.

A
  1. Man - Show manual page for a command. Look up what a command does
  2. Cat - concatenate files and print on the standard output
  3. Ls list directory content. - what directories we have
  4. Pwd to find out current directory you are in
  5. Echo - display line of text/string that passed as an argument
  6. Touch create a blank text file, Before creating a text file, it was used to change file access and modification time
  7. Mkdir create a new directory(folder)
  8. Mv - move a file or folder, but also rename the text
  9. Rm permanently remove a file or directory
  10. Cp - copy a file and can move to another directory
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Command-line-basics

What are the three virtues of a great programmer?

A
  1. Laziness: The quality that makes you go to great effort to reduce overall energy expenditure. It makes you write labor-saving programs that other people will find useful and document what you wrote so you don’t have to answer so many questions about it.
  2. Impatience: The anger you feel when the computer is being lazy. This makes you write programs that don’t just react to your needs, but actually anticipate them. Or at least pretend to.
  3. Hubris: The quality that makes you write (and maintain) programs that other people won’t want to say bad things about.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Node-Intro

What is Node.js?

A

Node.js is a program that allows JavaScript to be run outside of a web browser.

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

Node-Intro

What can Node.js be used for?

A

Node.js can be used to build back ends for web applications, command-line programs or any kind of automation that developers wish to perform.

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

Node-Intro

What is a REPL?

A

Read-Evaluate-Print-Loop

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

Node-Intro

When was Node.js created?

A

May 27, 2009

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

Node-Intro

What back end languages have you heard of?

A

C++, C#, Ruby, PHP

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Node-process-argv | What is the process object in a Node.js program?
The process object is a global that provides information about, and control over, the current Node.js process.
26
Node-process-argv | How do you access the process object in a Node.js program?
Type the process
27
Node-process-argv | What is the data type of process.argv in Node.js?
Array
28
Node-module-system | What is a JavaScript module?
It is a single .js file | Each file considers own module
29
Node-module-system | What values are passed into a Node.js module's local scope?
Exports, require, module, __filename, __dirname
30
Node-module-system Give two examples of truly global variables in a Node.js program.
process and console
31
Node-require | What is the purpose of module.exports in a Node.js module?
Assign a value and use it at some other file.
32
``` Node-require How do you import functionality into a Node.js module from another Node.js module? ```
Use require function and call the .js file
33
The-event-loop | What is the JavaScript Event Loop?
Look at the stack and task queue, if the stack is empty, it pushes callback to the stack
34
The-event-loop | What is different between "blocking" and "non-blocking" with respect to how code is executed?
Blocking- slow, block the execution of JavaScript until a certain long task has finished When blocking, prevent anything from happening. Nothing can happen. Non-blocking is the asynchronous that it wouldn’t block and accept call back function Push off to the side so that other codes can work.
35
node-fs-readfile | What is a directory?
Folder that contains multile files
36
node-fs-readfile | What is a relative file path?
file on the current working directory
37
node-fs-readfile | What is an absolute file path?
Root to all the way up to where the file is
38
``` node-fs-readfile What module does Node.js include for manipulating the file system? ```
fs module
39
``` node-fs-writefile What method is available in the Node.js fs module for writing data to a file? ```
fs.wrtieFile method
40
``` node-fs-writefile Are file operations using the fs module synchronous or asynchronous? ```
Asynchronous
41
http-message-recap | What is a client?
Service requester, requests content or service from a server | Program that requests to another program or computer
42
http-message-recap | What is a server?
The provider of a resource or service | The program listening to incoming response
43
http-message-recap | Which HTTP method does a browser issue to a web server when you visit a URL?
GET
44
http-message-recap | What is on the first line of an HTTP request message?
HTTP method 2. The request target 3. The HTTP version
45
http-message-recap | What is on the first line of an HTTP response message?
The protocol version 2. Status code 3. Status text | A typical status line looks like: HTTP/1.1 404 Not Found.
46
http-message-recap | What are HTTP headers?
General headers, response headers, representation headers HTTP headers let the client and the server pass additional information with an HTTP request or response. An HTTP header consists of its case-insensitive name followed by a colon (:), then by its value. Whitespace before the value is ignored.
47
http-message-recap Is a body required for a valid HTTP message?
No, not all requests have one: requests fetching sources like GET, HEAD, DELETE or OPTIONS, usually don’t need one. BUT some requests send data to the server in order to update it: as often the case with POST requests (containing HTML form data).
48
npm-intro | What is NPM?
Package manager for JavaScript Reeuse codes from other developers and share codes npm is the world’s largest software registry npm consists: the website, the command line interface(CLI) and the registry
49
npm-intro What is a package?
Directory with one or more files in it. | Collection of files that are together to make up single program/library
50
npm-intro How can you create a package.json with npm?
npm init —yes (default for setting)
51
npm-intro What is a dependency and how to you add one to a package?
Dependencies are specified in a simple object that maps a package name to a version range. You can add one to a package by npm i package name
52
npm-intro What happens when you add a dependency to a package with npm?
You get node_modules with jquery
53
Express-intro | How do you add express to your package dependencies?
npm i express
54
Express-intro What Express application method starts the server and binds it to a network PORT?
listen() method
55
express-hello-world | How do you mount a middleware with an Express application?
Use method With optional mount path. ‘/user/:id’ The path for which the middleware function is invoked;
56
express-hello-world Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
``` Call back method Request object(req), response object(res) and the next middleware function(next) ```
57
express-get-json | What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?
application/json
58
express-delete What is the significance of an HTTP request's method?
HTTP defines a set of request methods to indicate the desired action to be performed for a given resource. Although they can also be nouns, these request methods are sometimes referred to as HTTP verbs.
59
express-post-json What does the express.json() middleware do and when would you need it?
express.json() returns a middleware that only parses JSON and only looks at request where the Content-Type header matches the type option. This parser accepts Parse incoming base body, Needed when send data to the server
60
postgres-intro What is PostgreSQL and what are some alternative relational databases?
PostgreSQL is a powerful, open source object-relational database system Other popular relational databases include MySQL, SQL Server by Microsoft, and Oracle by Oracle Corporation
61
postgres-intro What are some advantages of learning a relational database?
If you are storing related data, then a relational database is probably a good first choice. A quality of many relational databases is that they support good guarantees about data integrity. They can store and modify data in a way that makes data corruption as unlikely as possible. This means that developers can set up their database to reject “bad” data and not worry about data being “half written”.
62
postgres-intro What is one way to see if PostgreSQL is running?
Sudo service postgresql status
63
postgres-database What is a database schema?
A collection of tables is called a schema. A schema defines how the data in a relational database should be organized.
64
postgres-database What is a table?
A table is a list of rows like a spreadsheet where each row is a record in that spreadsheet. The Table is made of columns and rows and each row has the same set of attributes.
65
postgres-database What is a row?
Row has the same set of attributes | Row is where the data is stored.
66
SQL-select What is SQL and how is it different from languages like JavaScript?
SQL is Structured Query Language. SQL interact with database. SQL is a declarative programming language. In declarative languages, programmers describe the results they want and the programming environment comes up with its own plan for getting those results unlinke JavaScript which is imperative programming language that basically programers tell the JavaScript runtime what to do and how to do it .
67
SQL-select How do you retrieve specific columns from a database table?
1. The query starts with the select keyword 2. The select keyword is followed by a comma-separated list of column names, each surrounded by “ double quotes. 3. The column names are followed by a from clause specifying which table to retrieve the data from. 4. The query must end in a ; semicolon
68
SQL-select How do you filter rows based on some specific criteria?
where clause 1. The where clause comes after the from clause 2. The where clause is checking the “category” of each row in the table 3. Text value, such as ‘cleaning’ are wrapped in a single quote. Not double quotes! 4. The value of the text value column is being compared using a single = equal sign.
69
SQL-select What are the benefits of formatting your SQL?
Makes it easier to read, maintain, and edit
70
SQL-select What are four comparison operators that can be used in a where clause?
Equal sign(=), greater than(>), less than (>), and not equal to sign (!=)
71
SQL-select How do you limit the number of rows returned in a result set?
1. The limit clause comes last 2. The limit clause includes a literal integer number with no quote to specify the maximum number of rows that should be returned
72
SQL-select How do you retrieve all columns from a database table?
The * asterisk is followed by the select keyword
73
SQL-select How do you control the sort order of a result set?
1. The order by clause comes after the from clause. 2. The order by clause is followed by a column name in " double quotes. 3. The default sort order of the results is ascending order.
74
SQL - Insert | How do you add a row to a SQL table?
Use insert statement to add rows to a table
75
SQL - Insert What is a tuple?
A tuple is a list of values
76
SQL - Insert How do you add multiple rows to a SQL table at once?
Separate more than one tuple of values separated by comma
77
SQL - Insert How do you get back the row being inserted into a table without a separate select statement?
Returning clause with * asterisk | Returning only works with insert, update and delete
78
SQL-Update | How do you update rows in a database table?
Use update statment and set column to value and specify where(which one)
79
SQL-Update Why is it important to include a where clause in your update statements?
Because if we don’t put the where clause to specify which one to update, every row will be updated with the same value.
80
SQL-Delete | How do you delete rows from a database table?
Delete statement where clause and returning clause
81
SQL-Delete How do you accidentally delete all rows from a table?
Delete from table name and don’t specify which row you want to delete not indicating where clause
82
SQL-Join | What is a foreign key?
Instead of putting all information into one row, use one column that links two different SQL tables Any columns that link tables together
83
SQL-Join | How do you join two SQL tables?
Join clause
84
SQL-Join | How do you temporarily rename columns or tables in a SQL statement?
Table name as keyword rename in the from and join clauses
85
SQL-Aggregates | What are some examples of aggregate functions?
max(), avg(), count(), min(), sum(), every()
86
SQL-Aggregates | What is the purpose of a group by clause?
The purpose is to separate rows into groups and perform aggregate function on those groups of rows.
87
es6-Promises | What are the three states a Promise can be in?
Pending: initial state, neither fulfilled nor rejected Fulfilled: meaning that the operation was completed successfully Rejected: meaning that the operation failed
88
es6-Promises | How do you handle the fulfillment of a Promise?
Then method passing resolve callback function with resolve value
89
es6-Promises | How do you handle the rejection of a Promise?
Catch method passing reject callback function with rejec value, error object
90
Array-filter | What is Array.prototype.filter useful for?
Filter in array and get a new array with filtered out result. Does not affect the original array
91
Array-map | What is Array.prototype.map useful for?
The map()method creates a new array populated with the results of calling a provided function on every element in the calling array.
92
Array-reduce | What is Array.prototype.reduce useful for?
The reduce() method is used to calculate a single value from an array. In other terms, the reduce() method reduces an array into a single value.