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
Q

Node-process-argv

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

Node-process-argv

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

A

Type the process

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

Node-process-argv

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

A

Array

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

Node-module-system

What is a JavaScript module?

A

It is a single .js file

Each file considers own module

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

Node-module-system

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

A

Exports, require, module, __filename, __dirname

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

Node-module-system

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

A

process and console

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

Node-require

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

A

Assign a value and use it at some other file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
32
Q
Node-require
How do you import functionality into a Node.js module from another Node.js module?
A

Use require function and call the .js file

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

The-event-loop

What is the JavaScript Event Loop?

A

Look at the stack and task queue, if the stack is empty, it pushes callback to the stack

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

The-event-loop

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

A

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.

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

node-fs-readfile

What is a directory?

A

Folder that contains multile files

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

node-fs-readfile

What is a relative file path?

A

file on the current working directory

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

node-fs-readfile

What is an absolute file path?

A

Root to all the way up to where the file is

38
Q
node-fs-readfile
What module does Node.js include for manipulating the file system?
A

fs module

39
Q
node-fs-writefile
What method is available in the Node.js fs module for writing data to a file?
A

fs.wrtieFile method

40
Q
node-fs-writefile
Are file operations using the fs module synchronous or asynchronous?
A

Asynchronous

41
Q

http-message-recap

What is a client?

A

Service requester, requests content or service from a server

Program that requests to another program or computer

42
Q

http-message-recap

What is a server?

A

The provider of a resource or service

The program listening to incoming response

43
Q

http-message-recap

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

A

GET

44
Q

http-message-recap

What is on the first line of an HTTP request message?

A

HTTP method 2. The request target 3. The HTTP version

45
Q

http-message-recap

What is on the first line of an HTTP response message?

A

The protocol version 2. Status code 3. Status text

A typical status line looks like: HTTP/1.1 404 Not Found.

46
Q

http-message-recap

What are HTTP headers?

A

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
Q

http-message-recap

Is a body required for a valid HTTP message?

A

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
Q

npm-intro

What is NPM?

A

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
Q

npm-intro

What is a package?

A

Directory with one or more files in it.

Collection of files that are together to make up single program/library

50
Q

npm-intro

How can you create a package.json with npm?

A

npm init —yes (default for setting)

51
Q

npm-intro

What is a dependency and how to you add one to a package?

A

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
Q

npm-intro

What happens when you add a dependency to a package with npm?

A

You get node_modules with jquery

53
Q

Express-intro

How do you add express to your package dependencies?

A

npm i express

54
Q

Express-intro

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

A

listen() method

55
Q

express-hello-world

How do you mount a middleware with an Express application?

A

Use method

With optional mount path. ‘/user/:id’ The path for which the middleware function is invoked;

56
Q

express-hello-world

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

A
Call back method
Request object(req), response object(res) and the next middleware function(next)
57
Q

express-get-json

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

A

application/json

58
Q

express-delete

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

A

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
Q

express-post-json

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

A

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
Q

postgres-intro

What is PostgreSQL and what are some alternative relational databases?

A

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
Q

postgres-intro

What are some advantages of learning a relational database?

A

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
Q

postgres-intro

What is one way to see if PostgreSQL is running?

A

Sudo service postgresql status

63
Q

postgres-database

What is a database schema?

A

A collection of tables is called a schema. A schema defines how the data in a relational database should be organized.

64
Q

postgres-database

What is a table?

A

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
Q

postgres-database

What is a row?

A

Row has the same set of attributes

Row is where the data is stored.

66
Q

SQL-select

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

A

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
Q

SQL-select

How do you retrieve specific columns from a database table?

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

SQL-select

How do you filter rows based on some specific criteria?

A

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
Q

SQL-select

What are the benefits of formatting your SQL?

A

Makes it easier to read, maintain, and edit

70
Q

SQL-select

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

A

Equal sign(=), greater than(>), less than (>), and not equal to sign (!=)

71
Q

SQL-select

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

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

SQL-select

How do you retrieve all columns from a database table?

A

The * asterisk is followed by the select keyword

73
Q

SQL-select

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

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

SQL - Insert

How do you add a row to a SQL table?

A

Use insert statement to add rows to a table

75
Q

SQL - Insert

What is a tuple?

A

A tuple is a list of values

76
Q

SQL - Insert

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

A

Separate more than one tuple of values separated by comma

77
Q

SQL - Insert

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

A

Returning clause with * asterisk

Returning only works with insert, update and delete

78
Q

SQL-Update

How do you update rows in a database table?

A

Use update statment and set column to value and specify where(which one)

79
Q

SQL-Update

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

A

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
Q

SQL-Delete

How do you delete rows from a database table?

A

Delete statement where clause and returning clause

81
Q

SQL-Delete

How do you accidentally delete all rows from a table?

A

Delete from table name and don’t specify which row you want to delete not indicating where clause

82
Q

SQL-Join

What is a foreign key?

A

Instead of putting all information into one row, use one column that links two different SQL tables
Any columns that link tables together

83
Q

SQL-Join

How do you join two SQL tables?

A

Join clause

84
Q

SQL-Join

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

A

Table name as keyword rename in the from and join clauses

85
Q

SQL-Aggregates

What are some examples of aggregate functions?

A

max(), avg(), count(), min(), sum(), every()

86
Q

SQL-Aggregates

What is the purpose of a group by clause?

A

The purpose is to separate rows into groups and perform aggregate function on those groups of rows.

87
Q

es6-Promises

What are the three states a Promise can be in?

A

Pending: initial state, neither fulfilled nor rejected
Fulfilled: meaning that the operation was completed successfully
Rejected: meaning that the operation failed

88
Q

es6-Promises

How do you handle the fulfillment of a Promise?

A

Then method passing resolve callback function with resolve value

89
Q

es6-Promises

How do you handle the rejection of a Promise?

A

Catch method passing reject callback function with rejec value, error object

90
Q

Array-filter

What is Array.prototype.filter useful for?

A

Filter in array and get a new array with filtered out result. Does not affect the original array

91
Q

Array-map

What is Array.prototype.map useful for?

A

The map()method creates a new array populated with the results of calling a provided function on every element in the calling array.

92
Q

Array-reduce

What is Array.prototype.reduce useful for?

A

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.