Senior Side Flashcards

1
Q

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

A

a chunk of code that will do a specific task when appropriate (when the function is called or a conditional is met/true)

Examples: if statement, for loop, while loop, etc

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

What does block scope mean?

A

the variables exist only within the corresponding block; variables are not visible outside the block

as opposed to function scoped

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

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: you can reassign them to different values, but you can’t redeclare; you don’t need to initialize it with a value
const: immutable so you can’t reassign them to different values, nor can you redeclare; requires an initializer, const key-words are read-only variables

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

the reference to the variable is immutable but the value of the variable is not so you can manipulate it

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

determine whether or not you will need to reassign said variable; if you will need to reassign it at some point, use let. If not, you can 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

wrap the string in backticks

any expressions or variables go inside curly braces with a dollar sign before

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

What is “string interpolation”?

A

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 destructuring, conceptually?

A

taking properties and values from an object and assigning their values to independent variable

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 {names you want to assign to your variables} = object

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 [names you want to assign to your variables] = array

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

where the brackets/curly braces are

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

param => expression
( ) => expression
(param1, param2, … ) => expression

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

without curly braces, implicit return will happen
if no curly braces, the expression must be a single expression

can’t have statements (eg. return, if, for loops etc)

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

an arrow function captures the this value of the enclosing context instead of creating its own this context

doesn’t have its own this value
lexical scope: where you wrote it
this is defined at the call time of its outer function (lexical scope)

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

What is a CLI?

A

Command-line interface processes commands to a computer program in the form of lines of text

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

What is a GUI?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q
Give at least one use case for each of the commands listed in this exercise.
man
cat
ls
pwd
echo
touch
mkdir
mv
rm
cp
A

man- interface to online reference manuals (use when there’s a command you don’t know much about)

cat- concatenate files and print on the standard output (use when you want to see contents of file or even combine files together in a new file)

ls- list directory contents (when you want to see what is inside the current directory)
(-a do not ignore entries that start with .
- F append indicator to entries)

pwd- print name of current/working directory ( when you want to know which directory you are in currently)

echo- display a line of text (when you want to display text and possibly put that text into a file)

touch- create new files

mkdir- make directories
(-p makes parent directories as needed)

mv- rename files/directories

rm- delete files
(-r removes directories and all their contents
-f ignore nonexistent files and arguments, never prompt)

cp- copy files and directories
(-r copy directories recursively)

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

What are the three virtues of a great programmer?

A

Laziness, Impatience, Hubris

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

What is Node.js?

A

a program that allows JavaScript to be run outside of a web browser

an asynchronous event-driven JavaScript runtime

Node.js is a set of libraries for JavaScript which allows it to be used outside of the browser

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

What can Node.js be used for?

A

used to build back ends for Web applications, command-line programs, or any kind of automation that developers wish to perform

It is primarily focused on creating simple, easy-to-build network clients and servers

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

What is a REPL?

A

Read-Eval-Print-Loop

an interactive toplevel or language shell, is a simple interactive computer programming environment that takes single user inputs, executes them, and returns the result to the user

An example of a repl is the inspect tools

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

When was Node.js created?

A

2009

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

What back-end languages have you heard of?

A

Python, Ruby, php, Java, C#, Perl, coldfusion, Scala, JavaScript, Go, Rust, C, C++, cobol, kotlin, clojure, crystal, elixir, erlang

.net (framework in C#)
SQL (database)

frameworks are libraries written within a language

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

What is a computer process?

A

a program or task running on your computer

program: like the code you want to run
process: like the code actually running

the instance of a computer program that is being executed by one or many threads. It contains the program code and its activity

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

Roughly how many computer processes are running on your host operating system (Task Manager or Activity Monitor)?

A

665

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

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

A

front-end and back-end are two different processes

if we’re trying to send a request to the back-end and it’s not working, we need to make sure the back-end process is actually running

for a full-stack app to work we need a front-end process (Chrome), a back-end process (Node.js), and a database process (PostSQL?)

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

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

A

you can just console.log process to access the process object; since its global, it’s always available to Node.js applications

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

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

A

array of strings

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

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

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

A

process, global, console, URL, clearImmediate(immediateObject), clearInterval(intervalObject), clearTimeout(timeoutObject)

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

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

A

allows for variables in one module to be used in another file

module exports is an empty object that allows you to put modules inside that you want to be exported and used in other files when using the require function

it gives you access to what modules are being exported

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

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

A

using the require function when you pass in a string of the ID or the path of the module you want to import

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

What is the JavaScript Event Loop?

A

orchestrates asynchronous functions (so our callback functions)

the event loop checks the call stack and the task queue, if the call stack is empty it looks to the task queue, takes the first thing on the queue, and places it on the stack

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

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

A

blocking is when there is code that is slow on the call stack. this becomes an issue because blocking that stack means the browser can’t do anything while it waits for everything to run

blocking methods execute synchronously
non-blocking methods execute asynchronously

if there’s a code running, no other code can be running
blocking is anything that just sits on the call stack until it is complete
non-blocking is something that is deferred to the task queue that waits to be executed

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

What is a directory?

A

a directory is a file system cataloging structure which contains references to other computer files, and possibly other directories

we call them folders on computers but folders are just icons lol

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

What is a relative file path?

A

location relative to the current directory

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

What is an absolute file path?

A

contains the root which you can see started by a forward slash, and a directory list to get where you need to be

where is this thing in the entire system

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

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

A

writeFile

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

Are file operations using the fs module synchronous or asynchronous?

A

asynchronous by default

if it says Sync at the end of the method then it’s synchronous

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

What is NPM?

A

the world’s largest software registry where developers can share and borrow packages

made of the website, CLI, and a registry
CLI is a way to add or get stuff from the website and the registry

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

What is a package?

A

modules, bits of reusable code, if it has a package.json, then it is considered a package

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

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

A

GET

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

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

A
  1. HTTP method (GET, POST, etc)
  2. The request target (usually a URL)
  3. HTTP version
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
48
Q

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

A
  1. Protocol version
  2. Status code
  3. Status text
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
49
Q

What are HTTP headers?

A

they allow the client and server to pass additional information with an HTTP request or response

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

Is a body required for a valid HTTP message?

A

no it’s optional

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

What is a package?

A

modules, bits of reusable code, if it has a package.json, then it is considered a package
directory with one or more files in it PLUS a package.json

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

How do you add express to your package dependencies?

A

npm install express

The difference between these two, is that devDependencies are modules which are only required during development, while dependencies are modules which are also required at runtime

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

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

A

listen method

Binds and listens for connections on the specified host and port

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

How do you mount a middleware with an Express application?

A

use the use method of the app object

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

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

A

request object, response object

56
Q

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

A

application/json

57
Q

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

A

it’s just semantics, it’s a way for the developer to express intent; the callback function is what determines what happens

but the request method and the request target has to match the path, then the callback will run

58
Q

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

A

it returns a middleware that gives your app the ability to parse json, we need it when you expect client requests that have json bodies

59
Q

What is PostgreSQL and what are some alternative relational databases?

A

powerful, free, open-source Relational Database Management System (RDBMS)

MySQL, SQLserver and Oracle

Postgres is an object-relational database, while MySQL is a purely relational database. This means that Postgres includes features like table inheritance and function overloading, which can be important to certain applications. Postgres also adheres more closely to SQL standards

60
Q

What are some advantages of learning a relational database?

A

security, organized, relational model is commonly used so it’s easier to pick up on other databases, lets you store data related to each other

61
Q

What is one way to see if PostgreSQL is running?

A

sudo service postgresql status command, top command, check with pgweb

62
Q

What is a database schema?

A

a collection of tables

A schema defines how the data in a relational database should be organized

63
Q

What is a table?

A

“relations”

a list of rows each having the same set of attributes

64
Q

What is a row?

A

a data record within a table, representing a record of a specific item

65
Q

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

A

SQL (structured query language) is the primary way of interacting with relational databases. It’s a powerful way of retrieving, creating, and manipulating data in a relational database

SQL is a declarative programming language whereas JS is an imperative programming language.
you describe the results and the programming environment comes up with its own plan to do it

66
Q

How do you retrieve specific columns from a database table?

A

select statement
select keyword followed by a comma-separated list of column names surrounded by double quotes; column names are followed by the from clause specifying which table to get data from

67
Q

How do you filter rows based on some specific criteria?

A

using the where clause followed by an expression

the comparison will come out as true or false

68
Q

What are the benefits of formatting your SQL?

A

having a consistent style and helps with readability

69
Q

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

A

=, less than, greater than, !=

70
Q

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

A

limit clause

limit keyword and maximum results you want

71
Q

How do you retrieve all columns from a database table?

A

select *

probably better practice, however, to list everything out even if you want them all

72
Q

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

A

order by clause
you can also use the desc keyword for descending order

by default, the order is not predictable

73
Q

How do you add a row to a SQL table?

A

using an insert statement

INSERT INTO table_name(column1, column2, …)
VALUES (value1, value2, …);

74
Q

What is a tuple?

A

a list of values, similar to arrays in JS, can be a mix of datatypes

75
Q

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

A

by specifying more than one tuple of values, separated by commas

76
Q

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

A

returning clause

77
Q

How do you update rows in a database table?

A

update statement with a set clause

78
Q

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

A

if you don’t include a where clause, it will update every row in the database

is there a way to undo that change or is it permanent

79
Q

How do you delete rows from a database table?

A

delete statement

80
Q

How do you accidentally delete all rows from a table?

A

if you don’t include a where clause you can delete everything by accident

81
Q

What is a foreign key?

A

a key that’s used to link two tables together

82
Q

How do you join two SQL tables?

A

use a “from” clause listing the table you want to select from followed by a “join” clause indicating which table you want to join and a “using” keyword to instruct the database server what to join them by

83
Q

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

A

column/table aliasing by using the “as” keyword

you would put the original name on the left of the “as” keyword and the alias name on the right of the “as” keyword

84
Q

What are some examples of aggregate functions?

A

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

85
Q

What is the purpose of a group by clause?

A

instead of having to ask a question to every row, you can group rows together and then do the aggregate functions on the groups of rows, more efficient

86
Q

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.

87
Q

How do you handle the fulfillment of a Promise?

A

then method on the promise object

when the promise transitions from pending to fulfilled, then the callback

88
Q

How do you handle the rejection of a Promise?

A

catch method on the promise object

89
Q

What is Array.prototype.filter useful for?

A

for when you need values from an array with a specific condition

90
Q

What is Array.prototype.map useful for?

A

for performing a specific task on all elements of a given array

91
Q

What is Array.prototype.reduce useful for?

A

when you want to accumulate values in a given array and return their combined value

92
Q

What is “syntactic sugar”?

A

syntax in a programming language that makes it easier to read/write

syntactic sugar if it can be removed from the language without any effect on what the language can do: functionality and expressive power will remain the same

example:
get_array(Array, vector( i , j ))
can be expressed as
Array[ i ][ j ]

93
Q

What is the typeof an ES6 class?

A

function

classes are syntactic sugar over prototypal inheritance

94
Q

Describe ES6 class syntax.

A

class keyword, optional class name, body

constructor function within the body
0 or more method definitions within the body

95
Q

What is “refactoring”?

A

improving the design, structure, and/or implementation of the software while preserving its functionality

the behavior of the system does not change

96
Q

What is Webpack?

A

a tool that lets you bundle your JavaScript applications (supporting both ESM and CommonJS), and it can be extended to support many different assets such as images, fonts, and stylesheets

an open-source JavaScript module bundler. It is made primarily for JavaScript, but it can transform front-end assets such as HTML, CSS, and images if the corresponding loaders are included. webpack takes modules with dependencies and generates static assets representing those modules

97
Q

How do you add a devDependency to a package?

A

npm install –save-dev

to add dependencies you’d use :
npm install [–save-prod]
** –save-prod is default of npm install so its optional to include

98
Q

What is an NPM script?

A

npm scripts are simply terminal commands that when run will do a specific task, we find them in the scripts object of our package.json

99
Q

How do you execute Webpack with npm run?

A

npm run command

most common to use npm run build

100
Q

How are ES Modules different from CommonJS modules?

A

ES syntax is more compact

ES has support for asynchronous loading and configurable module loading.

101
Q

What is React?

A

React.js is a JavaScript library that can be used to build user interfaces

102
Q

What is a React element?

A

return value of the createElement method

what shows up on the page

103
Q

What is a React element?

A

return value of the createElement method, object

what shows up on the page

104
Q

What is Babel?

A

a JavaScript compiler

mainly used to convert ECMAScript 2015+ code into a backwards compatible version of JavaScript in current and older browsers or environments

105
Q

What is Babel?

A

a JavaScript compiler

mainly used to convert ECMAScript 2015+ code into a backward-compatible version of JavaScript in current and older browsers or environments

106
Q

What is a Webpack loader?

A

an npm module that helps webpack to collect code from all the files in your application written in a certain language and converts them to

107
Q

How can you make Babel and Webpack work together?

A

install them as a devdependencies

108
Q

How can you make Babel and Webpack work together?

A

install babel as a dev dependency

109
Q

What is JSX?

A

a syntax extension to JavaScript

110
Q

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

A

Babel compiles JSX down to React.createElement( ) calls

111
Q

How can you make Webpack and Babel work together to convert JSX into valid JavaScript?

A

using babel-loader and adding the plugin @babel/plugin-transform-react-jsx

112
Q

What is a React component?

A

they are like JS functions that return React elements that describe what you should see on the screen

113
Q

How do you define a function component in React?

A

function keyword, function identifier, followed by parameter props and curly braces for the code block

114
Q

How do you mount a component to the DOM?

A

render method

115
Q

What are props in React?

A
props are objects
React Props (short for properties) are like function arguments in JavaScript and attributes in HTML... pass props as an argument to function component
116
Q

How do you pass props to a component?

A
117
Q

How do you write JavaScript expressions in JSX?

A

you put them inside curly braces

118
Q

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

A
class [ComponentName] extends React.Component {
   render( ) {
      return reactElement
   }
}
119
Q

How do you access props in a class component?

A

this keyword

120
Q

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

A

array.map( )

121
Q

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

A

a string that uniquely identifies a list item amongst its siblings; good to use IDs from your data if data has one

122
Q

What are controlled components?

A

An input form element whose value is controlled or driven by the React state

123
Q

What two props must you pass to an input for it to be “controlled”?

A

onChange

value

124
Q

What does fetch() return?

A

It returns a promise containing the response (Response object)
A Promise that resolves to a Response object

125
Q

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

A

GET

126
Q

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

A

add the method type by making the second argument an object, the key “method” and the value a string of the method you want to use

pass in an object of options, one of those being method

127
Q

When does React call a component’s componentDidMount method?

A

invoked immediately after a component is mounted (inserted into the tree)

React runs it ONCE after the first successful render

128
Q

Name three React.Component lifecycle methods.

A

constructor(),
render(),
component­Did­Mount(),
(these three run in this order)

componentDidUpdate(), componentWillUnmount()

129
Q

How do you pass data to a child component?

A

you pass the data as a prop

130
Q

What does express.static() return?

A

middleware function in Express. It serves static files

131
Q

What must the return value of myFunction be if the following expression is possible?
myFunction()();

A

the return value of myFunction’s return value

in other words the return value of the inner function

132
Q
What does this code do?
const wrap = value => () => value;
A

value if a function that returns an arrow function

the return of the inner function is being assigned to the variable wrap?

133
Q

What must the return value of myFunction be if the following expression is possible?
myFunction()();

A

a function

134
Q
What does this code do?
const wrap = value => () => value;
A

it returns the second function

135
Q

In JavaScript, when is a function’s scope determined; when it is called or when it is defined?

A

its determined when and WHERE it is defined

lexical scope means the function scope is determined when defined; it means you can tell its scope by just looking at it/where its defined