BackEnd Flashcards

1
Q

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

A
  1. lexical structure of source code that are grouped together. Code Blocks consist of one or more declarations and statements. (lexiscope refers to setting the scope, or range of functionality, of a variable so that it may be called (referenced) from within the block of code in which it is defined.)
  2. In JavaScript, code blocks are denoted by curly braces { }.
  3. For example, if else, for, do while, while and so on.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does block scope mean?

A

Block scope means the variable definition is only valid within the block of code that it was declared in.

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

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

A

const and let variables are Block-Scoped.

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

What is the difference between let and const?

A

Let can be reassigned and Const cannot.

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

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

A

It is possible to .push() to a new value into a const variable, because it is adding to the array instead of reassigning the variable.

The values in the array are mutable.

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

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

A

If the variable does not needed to be reassigned, then use const

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

What is the syntax for writing a template literal?

A
  1. put it inside backticks (``)
  2. ${ } holds the expressions and variables

example:
let name = ‘sharon’;
let age = 26;

phrase = hi my name is ${ name } and I am ${ age } years old;

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

What is “string interpolation”?

A

String formatting: the ability to substitute part of the string for the values of variables or expressions.

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

What is restructuring conceptually?

A

Taking out part of an object and assigning it to new variables

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

What is the syntax for Object destructuring?

A

const { title, author, libraryID } = book1

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

What is the syntax for Array destructuring?

A

const [ book3, book4, book5 ] = getBooks()

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

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

A

the side of the assignment operator that the object or array is on.

creating object : def is right side of the equal sign
restructuring: { } and property name is on the left side of the =

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

What is the syntax for defining an arrow function?

A

functionName = parameter => {
code block
}

functionName = () => { }

() not needed with one parameter
() are needed with no parameter

{} needed for more than one line of code

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

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

A

You don’t get a return statement.

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

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

A

this is defined at definition time for arrow functions. In other words, THIS is defined within the same lexiscope or parentscope.

For other functions, this is determined at call time

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

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

What can Node.js be used for?

A

Building 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
18
Q

What is a REPL?

A

A read–eval–print loop (REPL), also termed an interactive top-level or language shell, is a simple interactive computer programming environment that takes single user inputs, executes them, and returns the result to the user; a program written in a REPL environment is executed piecewise.

Chrome Dev Tools Console is one example.

This is more like a playground for testing things.

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

What back end languages have you heard of?

A

Node, Python, PHP, Ruby

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

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

A

• The process object is a global
• that global informs about and controls the current Node.js process.
• As a global, it is always available to Node.js applications without using require().
• It can also be explicitly accessed using require():

const process = require(‘process’);

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

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

A

Just type process, it is always available. Treat it like any other object.

It is a global so you can access it anywhere.

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

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

What is a JavaScript module?

A

Module in Node.js is a functionality organized in single or multiple JavaScript files that are reused.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What values are passed into a Node.js module's local scope?
exports, require, module, __filename, __dirname
26
Give two examples of truly global variables in a Node.js program.
Console, process, global
27
What is the purpose of module.exports in a Node.js module?
It exports a module so other modules can use it
28
How do you import functionality into a Node.js module from another Node.js module?
Using the require function
29
What is the purpose of module.exports in a Node.js module?
Module exports are the instructions that tell Node. js which bits of code (functions, objects, strings, etc.) to export from a given file so that other files are allowed to access the exported code.
30
How do you import functionality into a Node.js module from another Node.js module?
Blocking assignment executes "in series" because a blocking assignment blocks execution of the next statement until it completes. Non-blocking assignment executes in parallel because it describes assignments that all occur at the same time.
31
What is a directory?
An organizational structure and location for storing files.
32
What is a relative file path?
The location that is relative to where the file is. ./fileName
33
What is an absolute file path?
The path of the file from the root directory. (This is not a good idea to use because what is an absolute file path on my computer might not be the same for someone else's computer).
34
What module does Node.js include for manipulating the file system?
the fs module
35
What method is available in the Node.js fs module for writing data to a file?
fs.writeFile
36
Are file operations using the fs module synchronous or asynchronous?
Both, since there are different sync versions, but fs.writeFile is asynchronous Asynchronous take callback arguments
37
What is npm?
npm is the world's largest software registry. It can be used to share and borrow packages. It has three components: 1. the website 2. the Command Line Interface (CLI) 3. the registry
38
What is a package?
a package is a package or module of code to reuse. It needs to be a directory with one or more files. It has a package.JSON file.
39
How can you create a package.json with npm?
Run the "npm init --yes" command on the command line
40
What is a dependency and how to you add one to a package?
dependencies are the modules that the project relies on to function properly. npm install
41
What happens when you add a dependency to a package with npm?
The newly installed package(s) gets added to the list of dependencies in your package. json file It downloads the packages that it depends on until it has everything.
42
How do you add express to your package dependencies?
run this command in the terminal while you are in the package directory: npm install express
43
What Express application method starts the server and binds it to a network PORT?
listen( ) method. app.listen([port [, host [, backlog] ] ][, callback])
44
What is a client?
a client is a piece of computer hardware or software that accesses a service made available by a server as part of the client–server model of computer networks.
45
What is a server?
a server is a piece of computer hardware or software (computer program) that provides functionality for other programs or devices, called "clients".
46
Which HTTP method does a browser issue to a web server when you visit a URL?
GET
47
What is on the first line of an HTTP request message?
1.An HTTP method, 2. The request target, 3. The HTTP version
48
What is on the first line of an HTTP response message?
The protocol version, A status code, A status text.
49
What are HTTP headers?
It is meta-information about the request or describes the body included in the messages.
50
Is a body required for a valid HTTP message?
No. It is optional.
51
How do you mount a middleware with an Express application?
Middleware functions are functions that have access to the request object (req), the response object (res), They can be mounted with app.use app.use((req, res) => { } "the use method of the app object is being called with ONE argument with TWO PARAMETERS: req and use."
52
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
the request and response objects
53
What is the appropriate Content-Type
application/JSON
54
What is the significance of an HTTP request's method?
It tells what function your want to run in the code such as deleting and getting data in app.delete( ) and app.get( )
55
What does the express.json() middleware do and when would you need it?
parses incoming request bodies if payload is JSON. It is needed when content type header is application/json in the HTTP request. In other words, it is a function or a program (or something) that is going to run between the time that the server gets the request and the time that the server sends the request out to the client. It is a function that happens between the beginning of the response and sending of the response.
56
What is PostgreSQL and what are some alternative relational databases?
PostgreSQL is a powerful, free, open source Relational Database Management System (RDBMS). Other popular relational databases include MySQL (also free), SQL Server by Microsoft, and Oracle by Oracle Corporation.
57
What are some advantages of learning a relational database?
they can be modeled well, data corruption is very unlikely, categorize data, and they are widely used.
58
What is one way to see if PostgreSQL is running?
running this command in the terminal: sudo service postgresql status
59
What is SQL and how is it different from languages like JavaScript?
SQL is different! 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.JavaScript is imperative
60
How do you retrieve specific columns from a database table?
select "name", "other names"
61
How do you filter rows based on some specific criteria?
where "category" = 'cleaning';
62
What are the benefits of formatting your SQL?
makes it easier to read, understand, and debug it.
63
What are four comparison operators that can be used in a where clause?
1. Not equals 2. Greater than / greater than or equal to 3. lesser than / lesser than or equal to 4. Inclusive of two values (BETWEEN...AND)
64
How do you limit the number of rows returned in a result set?
limit 1; at end of code (the limit clause then followed by the number)
65
How do you retrieve all columns from a database table?
Select*
66
How do you control the sort order of a result set?
order by priceDESC if you want descending instead of ascending order by clause, then DESC for descending order. The default is ascending order.
67
What is SQL and how is it different from languages like JavaScript?
SQL is different! 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.JavaScript is imperative
68
How do you retrieve specific columns from a database table?
select "name"
69
How do you filter rows based on some specific criteria?
use where class then the name of the column wrapped in double quotes, equal operator and then the value of the category wrapped in single quotes. where "category" = 'cleaning'
70
What are the benefits of formatting your SQL?
makes it easier to read, organize, and debug
71
What are four comparison operators that can be used in a where clause?
1. greater than or greater than or equal to 2. less than, less than or equal to 3. not equals to != 4. equals to =
72
How do you limit the number of rows returned in a result set?
limit 1; limit clause, then number of what your limit is but it is always at end of code.
73
How do you retrieve all columns from a database table?
select *
74
How do you control the sort order of a result set?
order the data by adding the keyword DESC at the end if your code if you want descending order. The default will always be ascending order.
75
How do you add a row to a SQL table?
INSERT INTO "products" ("name", "description", "price", "category") VALUES ('Ostrich Pillow', 'Feel comfy and cozy!', 99, 'self care');
76
What is a tuple?
In SQL, a list of values is referred to as a tuple.
77
How do you add multiple rows to a SQL table at once?
insert into "products" ("name", "description", "price", "category")values ('Ostrich Pillow', 'Feel comfy and cozy!', 99, 'self care'), ('Tater Mitts', 'Scrub some taters!', 6, 'cooking')returning *;
78
How do you get back the row being inserted into a table without a separate select statement?
If you only want specific values back, you can use a comma-separated list of column names instead of an * asterisk for the returning statement
79
What is a foreign key?
The column that links two tables together since it is in both tables
80
How do you join two SQL tables?
select "products"."name" as "product", "suppliers"."name" as "supplier" from "products" join "suppliers" using ("supplierId");
81
How do you temporarily rename columns or tables in a SQL statement?
Table aliasing likeselect "p"."name" as "product", "p"."category", "s"."name" as "supplier", "s"."state" from "products" as "p" join "suppliers" as "s" using ("supplierId");
82
What are some examples of aggregate functions?
sum, avg, count
83
What is the purpose of a group by clause?
when you want to separate rows into groups and perform aggregate functions on those groups of rows. This is done with a group by clause.
84
What are the three states a Promise can be in?
1. pending: initial state, neither fulfilled nor rejected. 2. fulfilled: meaning that the operation was completed successfully. 3. rejected: meaning that the operation failed.
85
How do you handle the fulfillment of a Promise?
attach a then method handler with callback function with success message
86
How do you handle the rejection of a Promise?
attach a catch method handler with callback function with error message
87
What is Array.prototype.filter useful for?
The filter() method creates a new array with all elements that pass the test implemented by the provided function.
88
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.
89
What is Array.prototype.reduce useful for?
Reduces an array of values to a smaller or one value.
90
What is "syntactic sugar"?
In computer science, syntactic sugar is syntax within a programming language that makes things easier to read or to express. It makes the language "sweeter" for human use: things can be expressed more clearly, more concisely, or in an alternative style that some may prefer. Syntactic sugar is usually a shorthand for a common operation that could also be expressed in an alternate, more verbose, form: The programmer has a choice of whether to use the shorter form or the longer form, but will usually use the shorter form since it is shorter and easier to type and read.
91
What is the typeof an ES6 class?
function
92
Describe ES6 class syntax.
class key word and curly braces: class ExampleClass { } const example = new ExampleClass { } class key word, name of function, function code block, constructor inside with arguments and then function code block: class Student { constructor( arguments, arguments) { this.firstName = firstName; this.lastName = lastName; this.subject = subject; } }
93
What is "refactoring"?
It changes the structure of the code by cleaning and reorganizing it without affecting or changing the functionality of it.
94
What is Webpack?
Webpack bundles multiple modules into a single JavaScript file. It is a tool that lets you bundle your JS applications and it can support many different assets such as images, fonts, and stylesheets.
95
How do you add a devDependency to a package?
$ npm install --save-dev
96
What is an NPM script?
something that automates repetitive tasks in package.json file, it is a command line command under script in the package.json
97
How do you execute Webpack with npm run?
npm run