Senior Side Flashcards

(135 cards)

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
What is a computer process?
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
26
Roughly how many computer processes are running on your host operating system (Task Manager or Activity Monitor)?
665
27
Why should a full-stack Web developer know that computer processes exist?
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?)
28
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
29
How do you access the process object in a Node.js program?
you can just console.log process to access the process object; since its global, it's always available to Node.js applications
30
What is the data type of process.argv in Node.js?
array of strings
31
What is a JavaScript module?
a single .js file
32
What values are passed into a Node.js module's local scope?
exports, require, module, _filename, _dirname
33
Give two examples of truly global variables in a Node.js program.
process, global, console, URL, clearImmediate(immediateObject), clearInterval(intervalObject), clearTimeout(timeoutObject)
34
What is the purpose of module.exports in a Node.js module?
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
35
How do you import functionality into a Node.js module from another Node.js module?
using the require function when you pass in a string of the ID or the path of the module you want to import
36
What is the JavaScript Event Loop?
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
37
What is different between "blocking" and "non-blocking" with respect to how code is executed?
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
38
What is a directory?
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
39
What is a relative file path?
location relative to the current directory
40
What is an absolute file path?
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
41
What module does Node.js include for manipulating the file system?
fs module
42
What method is available in the Node.js fs module for writing data to a file?
writeFile
43
Are file operations using the fs module synchronous or asynchronous?
asynchronous by default | if it says Sync at the end of the method then it's synchronous
44
What is NPM?
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
45
What is a package?
modules, bits of reusable code, if it has a package.json, then it is considered a package
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. HTTP method (GET, POST, etc) 2. The request target (usually a URL) 3. HTTP version
48
What is on the first line of an HTTP response message?
1. Protocol version 2. Status code 3. Status text
49
What are HTTP headers?
they allow the client and server to pass additional information with an HTTP request or response
50
Is a body required for a valid HTTP message?
no it's optional
51
What is a package?
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
52
How do you add express to your package dependencies?
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
53
What Express application method starts the server and binds it to a network PORT?
listen method | Binds and listens for connections on the specified host and port
54
How do you mount a middleware with an Express application?
use the use method of the app object
55
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
request object, response object
56
What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?
application/json
57
What is the significance of an HTTP request's method?
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
What does the express.json() middleware do and when would you need it?
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
What is PostgreSQL and what are some alternative relational databases?
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
What are some advantages of learning a relational database?
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
What is one way to see if PostgreSQL is running?
sudo service postgresql status command, top command, check with pgweb
62
What is a database schema?
a collection of tables | A schema defines how the data in a relational database should be organized
63
What is a table?
"relations" | a list of rows each having the same set of attributes
64
What is a row?
a data record within a table, representing a record of a specific item
65
What is SQL and how is it different from languages like JavaScript?
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
How do you retrieve specific columns from a database table?
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
How do you filter rows based on some specific criteria?
using the where clause followed by an expression | the comparison will come out as true or false
68
What are the benefits of formatting your SQL?
having a consistent style and helps with readability
69
What are four comparison operators that can be used in a where clause?
=, less than, greater than, !=
70
How do you limit the number of rows returned in a result set?
limit clause limit keyword and maximum results you want
71
How do you retrieve all columns from a database table?
select * probably better practice, however, to list everything out even if you want them all
72
How do you control the sort order of a result set?
order by clause you can also use the desc keyword for descending order by default, the order is not predictable
73
How do you add a row to a SQL table?
using an insert statement INSERT INTO table_name(column1, column2, …) VALUES (value1, value2, …);
74
What is a tuple?
a list of values, similar to arrays in JS, can be a mix of datatypes
75
How do you add multiple rows to a SQL table at once?
by specifying more than one tuple of values, separated by commas
76
How do you get back the row being inserted into a table without a separate select statement?
returning clause
77
How do you update rows in a database table?
update statement with a set clause
78
Why is it important to include a where clause in your update statements?
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
How do you delete rows from a database table?
delete statement
80
How do you accidentally delete all rows from a table?
if you don't include a where clause you can delete everything by accident
81
What is a foreign key?
a key that's used to link two tables together
82
How do you join two SQL tables?
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
How do you temporarily rename columns or tables in a SQL statement?
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
What are some examples of aggregate functions?
sum( ), max( ), min( ), every( ), avg( ), count( ), json aggregates
85
What is the purpose of a group by clause?
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
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.
87
How do you handle the fulfillment of a Promise?
then method on the promise object | when the promise transitions from pending to fulfilled, then the callback
88
How do you handle the rejection of a Promise?
catch method on the promise object
89
What is Array.prototype.filter useful for?
for when you need values from an array with a specific condition
90
What is Array.prototype.map useful for?
for performing a specific task on all elements of a given array
91
What is Array.prototype.reduce useful for?
when you want to accumulate values in a given array and return their combined value
92
What is "syntactic sugar"?
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
What is the typeof an ES6 class?
function | classes are syntactic sugar over prototypal inheritance
94
Describe ES6 class syntax.
class keyword, optional class name, body constructor function within the body 0 or more method definitions within the body
95
What is "refactoring"?
improving the design, structure, and/or implementation of the software while preserving its functionality the behavior of the system does not change
96
What is Webpack?
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
How do you add a devDependency to a package?
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
What is an NPM script?
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
How do you execute Webpack with npm run?
npm run command most common to use npm run build
100
How are ES Modules different from CommonJS modules?
ES syntax is more compact ES has support for asynchronous loading and configurable module loading.
101
What is React?
React.js is a JavaScript library that can be used to build user interfaces
102
What is a React element?
return value of the createElement method what shows up on the page
103
What is a React element?
return value of the createElement method, object what shows up on the page
104
What is Babel?
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
What is Babel?
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
What is a Webpack loader?
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
How can you make Babel and Webpack work together?
install them as a devdependencies
108
How can you make Babel and Webpack work together?
install babel as a dev dependency
109
What is JSX?
a syntax extension to JavaScript
110
Why must the React object be imported when authoring JSX in a module?
Babel compiles JSX down to React.createElement( ) calls
111
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
using babel-loader and adding the plugin @babel/plugin-transform-react-jsx
112
What is a React component?
they are like JS functions that return React elements that describe what you should see on the screen
113
How do you define a function component in React?
function keyword, function identifier, followed by parameter props and curly braces for the code block
114
How do you mount a component to the DOM?
render method
115
What are props in React?
``` 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
How do you pass props to a component?
117
How do you write JavaScript expressions in JSX?
you put them inside curly braces
118
How do you create a "class" component in React?
``` class [ComponentName] extends React.Component { render( ) { return reactElement } } ```
119
How do you access props in a class component?
this keyword
120
What Array method is commonly used to create a list of React elements?
array.map( )
121
What is the best value to use as a "key" prop when rendering lists?
a string that uniquely identifies a list item amongst its siblings; good to use IDs from your data if data has one
122
What are controlled components?
An input form element whose value is controlled or driven by the React state
123
What two props must you pass to an input for it to be "controlled"?
onChange | value
124
What does fetch() return?
It returns a promise containing the response (Response object) A Promise that resolves to a Response object
125
What is the default request method used by fetch()?
GET
126
How do you specify the request method (GET, POST, etc.) when calling fetch?
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
When does React call a component's componentDidMount method?
invoked immediately after a component is mounted (inserted into the tree) React runs it ONCE after the first successful render
128
Name three React.Component lifecycle methods.
constructor(), render(), component­Did­Mount(), (these three run in this order) componentDidUpdate(), componentWillUnmount()
129
How do you pass data to a child component?
you pass the data as a prop
130
What does express.static() return?
middleware function in Express. It serves static files
131
What must the return value of myFunction be if the following expression is possible? myFunction()();
the return value of myFunction's return value in other words the return value of the inner function
132
``` What does this code do? const wrap = value => () => value; ```
value if a function that returns an arrow function the return of the inner function is being assigned to the variable wrap?
133
What must the return value of myFunction be if the following expression is possible? myFunction()();
a function
134
``` What does this code do? const wrap = value => () => value; ```
it returns the second function
135
In JavaScript, when is a function's scope determined; when it is called or when it is defined?
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