Javascript Flashcards

1
Q

What is the purpose of variables?

A

To store some sort of value

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

How do you declare a variable?

A

var varName = value;

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

How do you initialize (assign a value to) a variable?

A

varName = newValue;

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

What characters are allowed in variable names?

A

Letters, numbers, underscore, $dollar_sign

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

What does it mean to say that variable names are “case sensitive”?

A

“THIS” is different from “this” and “tHiS”

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

What is the purpose of a string?

A

To represent letters and characters

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

What is the purpose of a number?

A

To represent numerical data

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

What is the purpose of a boolean?

A

Used as a trigger for a condition

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

What does the = operator mean in JavaScript?

A

It’s the assignment operator

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

How do you update the value of a variable?

A

Assign a new value on the right side of the = operator

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

What is the difference between null and undefined?

A

null points to a nonexistent address

Undefined is a value for variables not yet defined

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

Why is it a good habit to include “labels” when you log values to the browser console?

A

It helps you recognize why you are logging onto the console

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

Give five examples of JavaScript primitives.

A

Number, string, boolean, array, object

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

What data type is returned by an arithmetic operation?

A

number

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

What is string concatenation?

A

Joining two or more strings together

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

What purpose(s) does the + plus operator serve in JavaScript?

A

String concatenation, addition for numbers

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

What data type is returned by comparing two values (, ===, etc)?

A

boolean

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

What does the += “plus-equals” operator do?

A

Adds the given value and re-assigns the new value to the variable on the left hand side of the operator

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

What are objects used for?

A

A data type that groups together a set of variables and functions to model real life ‘objects’

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

What are object properties?

A

Variables that hold data unique to that object

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

Describe object literal notation.

A
Declared with var objName = { };
Properties are stored between curly braces separated by commas
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

How do you remove a property from an object?

A

delete obj.prop;

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

What are the two ways to get or update the value of a property?

A

Dot notation and bracket notation with assignment operator

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

What are arrays used for?

A

To store related data in an ordered list

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

Describe array literal notation.

A

Declare with var arrName

Assign: [val1, val2, …];

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

How are arrays different from “plain” objects?

A

You access its elements using indices

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

What number represents the first index of an array?

A

0

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

What is the length property of an array?

A

It returns the length of an array or how many elements that array contains

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

How do you calculate the last index of an array?

A

arr.length - 1

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

What is a function in JavaScript?

A

To pack code for reuse throughout a program

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

Describe the parts of a function definition.

A

Function keyword, functionName(optional), parameters(optional), {code block}, return value(optional)

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

Describe the parts of a function call.

A

Function name and argument(s)

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

When comparing them side-by-side, what are the differences between a function call and a function definition?

A

Function call doesn’t have the actual code, the function definition has the ‘function’ keyword

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

What is the difference between a parameter and an argument?

A

Parameters are defined in the function definition, arguments are passed in a function call

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

Why are function parameters useful?

A

They can be used to store data to be used (and sometimes modified) within a function

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

What two effects does a return statement have on the behavior of a function?

A

It exits a function immediately

It pushes a value out to where the function is called

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

Why do we log things to the console?

A

To keep track of the changes we make to our code and verifies our data. This prevents hard to find bugs because we’ll see it immediately with the log

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

What is a method?

A

Functions that are properties of an object

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

How is a method different from any other function?

A

Functions can only be called from an object through dot operator

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

How do you remove the last element from an array?

A

arr.pop();

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

How do you round a number down to the nearest integer?

A

Math.floor(num)

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

How do you generate a random number?

A

Math.random()

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

How do you delete an element from an array?

A

arr.splice(startIndex, deleteCount)

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

How do you append an element to an array?

A

arr.push(elem);

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

How do you break a string up into an array?

A

aString.split(‘delimiter’)

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

Do string methods change the original string? How would you check if you weren’t sure?

A

Strings are immutable meaning they cannot be changed. Log to console if you aren’t sure

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

Roughly how many string methods are there according to the MDN Web docs?

A

About 35 not including ‘deprecated’ methods (not recommended to use because some browsers won’t support)

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

Is the return value of a function or method useful in every situation?

A

No, pop() will return a value, but you don’t need to use it

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

Roughly how many array methods are there according to the MDN Web docs?

A

About 40

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

What three-letter acronym should you always include in your Google search about a JavaScript method or CSS property?

A

MDN

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

Give 6 examples of comparison operators.

A

> , >=.

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

What data type do comparison expressions evaluate to?

A

boolean

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

What is the purpose of an if statement?

A

To evaluate the boolean value of a conditional expression

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

Is else required in order to use an if statement?

A

No

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

Describe the syntax (structure) of an if statement.

A

If keyword, conditional statement between parentheses, code block to run if “if” statement is true

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

What are the three logical operators?

A

&& and, || or, ! logical not

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

How do you compare two different expressions in the same condition?

A

Use a logical operator between the two expressions

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

What is the purpose of a loop?

A

To run a block of code multiple times

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

What is the purpose of a condition expression in a loop?

A

To check if the loops should advance or not

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

What does “iteration” mean in the context of loops?

A

A single pass of the code block

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

When does the condition expression of a while loop get evaluated?

A

Before each iteration

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

When does the initialization expression of a for loop get evaluated?

A

Before the condition expression is checked for the first time
Only gets initialized once

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

When does the condition expression of a for loop get evaluated?

A

After initialization and before the block of code runs

Subsequent loops, the condition expression is evaluated after the final (updating) expression

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

When does the final expression of a for loop get evaluated?

A

At the end of each iteration

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

Besides a return statement, which exits its entire function block, which keyword exits a loop before its condition expression evaluates to false?

A

break

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

What does the ++ increment operator do?

A

Adds 1 to the variable and reassigns it back into the variable

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

How do you iterate through the keys of an object?

A

By using a for..in loop

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

What event is fired when a user places their cursor in a form control?

A

focus

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

What event is fired when a user’s cursor leaves a form control?

A

blur

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

What event is fired as a user changes the value of a form control?

A

input

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

What event is fired when a user clicks the “submit” button within a ?

A

submit

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

What does the event.preventDefault() method do?

A

prevents the browser from automatically reloading the page with the form’s values in the URL

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

What does submitting a form without event.preventDefault() do?

A

Reloads the page

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

What property of a form element object contains all of the form’s controls.

A

Elements (?)

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

What property of a form control object gets and sets its value?

A

value

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

What is one risk of writing a lot of code without checking to see if it works so far?

A

You might miss a hard-to-find bug further down the line

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

What is an advantage of having your console open when writing a JavaScript program?

A

To check for bugs or mistakes while writing

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

What is the event.target?

A

It references the object in which the event was directed at

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

What is the effect of setting an element to display: none?

A

It hides the element from view on the screen

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

What does the element.matches() method take as an argument and what does it return?

A

It takes a selector (string) as an argument and it returns boolean value (true if it matches)

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

How can you retrieve the value of an element’s attribute?

A

element.getAttribute(‘attributeName’)

Returns the value attached to the attribute

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

At what steps of the solution would it be helpful to log things to the console?

A

Pretty much each step logging to the console would be useful

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

If you were to add another tab and view to your HTML, but you didn’t use event delegation, how would your JavaScript code be written instead?

A

You would have to query each new tab and view DOM element and add an event listener to each one

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

If you didn’t use a loop to conditionally show or hide the views in the page, how would your JavaScript code be written instead?

A

You would have to write a stack of “if” and “else if” statements

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

What is JSON?

A

It stands for JavaScript Object Notation

It is a text-based data format which allows transmitting of data across networks

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

What are serialization and deserialization?

A

Serialization is converting a native object into a string for transmitting the data
Deserialization is the opposite of that

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

Why are serialization and deserialization useful?

A

It allows the transmitting and translating of data that, for the most part, can’t be transmitted

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

How do you serialize a data structure into a JSON string using JavaScript?

A

JSON.stringify(jsonObj)

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

How do you deserialize a JSON string into a data structure using JavaScript?

A
JSON.parse(jsonStr)
const jsonStr = ‘{ “prop”:”value” }’; // quotes around prop required
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
90
Q

How do you store data in localStorage?

A

window.localStorage.setItem( ‘prop-name’ , ‘jsonString’ )

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

How do you retrieve data from localStorage?

A

window.localStorage.getItem( ‘prop-name’ )

92
Q

What data type can localStorage save in the browser?

A

JSON string

93
Q

When does the ‘beforeunload’ event fire on the window object?

A

Before everything is unloaded

94
Q

What is a method?

A

A function that is a property of an object

95
Q

How can you tell the difference between a method definition and a method call?

A

A definition will have a block of code after the method’s name

96
Q

Describe method definition syntax (structure).

A

objectName = {

methodName: function (para) { return something } };

97
Q

Describe method call syntax (structure).

A

objectName.methodName(arguments);

98
Q

How is a method different from any other function?

A

A method can only be called on the object it is associated with

99
Q

What is the defining characteristic of Object-Oriented Programming?

A

The object

100
Q

What are the four “principles” of Object-Oriented Programming?

A

Abstraction, encapsulation, inheritance, polymorphism

101
Q

What is “abstraction”?

A

The process of taking a complex component of an object and making it more simplified to utilize its features

102
Q

What does API stand for?

A

Application programming interface

103
Q

What is the purpose of an API?

A

To allow users to utilize the abstraction of software & to share the functionality of a program

104
Q

What is this in JavaScript?

A

An implicit parameter of all JS functions or the object itself or the global window object when not attached explicitly to an object

105
Q

What does it mean to say that this is an “implicit parameter”?

A

It’s available in a function’s code block even when it’s not explicitly stated

106
Q

When is the value of this determined in a function; call time or definition time?

A

Call time

107
Q
What does this refer to in the following code snippet?
var character = {
  firstName: 'Mario',
  greet: function () {
    var message = 'It\'s-a-me, ' + this.firstName + '!';
    console.log(message);
  }
};
A

The character object

108
Q

Given the above character object, what is the result of the following code snippet? Why?
character.greet();

A

It’s-a-me, Mario!

this.firstName refers to the character object when calling the greet method

109
Q
Given the above character object, what is the result of the following code snippet? Why?
var hello = character.greet;
hello();
A

‘It’s-a-me, undefined!’

110
Q

How can you tell what the value of this will be for a particular function or method definition?

A

The value of ‘this’ will be determined at function/method call depending if it has something to the left of the dot operator

111
Q

How can you tell what the value of this is for a particular function or method call?

A

It will reference the object that is on the left of the dot operator. If there isn’t one, it will reference the global window object.

112
Q

What kind of inheritance does the JavaScript programming language use?

A

prototypal

113
Q

What is a prototype in JavaScript?

A

An object that contains properties that other objects can use

114
Q

How is it possible to call methods on strings, arrays, and numbers even though those methods don’t actually exist on objects, arrays, and numbers?

A

These methods are defined on a prototype object and then set to be used by strings, arrays, and numbers

115
Q

If an object does not have it’s own property or method by a given key, where does JavaScript look for it?

A

JS looks to see if it has a prototype property set in the prototype chain

116
Q

What does the new operator do?

A

It creates an instance of a user-defined object
Adds a property to the object (__proto__)
‘This’ now refer to the object created
Returns ‘this’ if function doesn’t return an object

117
Q

What property of JavaScript functions can store shared behavior for instances created with new?

A

The prototype property

118
Q

What does the instanceof operator do?

A

Returns a boolean if “var” is an instance created by a constructor of an object

119
Q

What is a “callback” function?

A

A function passed into another function as an argument

120
Q

Besides adding an event listener callback function to an element or the document, what is one way to delay the execution of a JavaScript function until some point in the future?

A

setTimeout(cbFn, delay);

121
Q

How can you set up a function to be called repeatedly without using a loop?

A

setInterval(cbFn, delay);

122
Q

What is the default time delay if you omit the delay parameter from setTimeout() or setInterval()?

A

0 or immediately

123
Q

What do setTimeout() and setInterval() return?

A

A timeout ID to store the timer’s ID. It can be used as an argument for clearTimeout()/clearInterval()

124
Q

What is a client?

A

A computer or program that sends requests to access services available from servers

125
Q

What is a server?

A

Hardware or software that provides functionality for other programs or devices after a request

126
Q

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

A

GET

127
Q

What three things are on the start-line of an HTTP request message?

A

HTTP method, request target, HTTP version

128
Q

What three things are on the start-line of an HTTP response message?

A
Protocol version (usually HTTP/1.1)
Status code (200, 404, 302, etc)
Status text (OK, NOT FOUND, etc)
129
Q

What are HTTP headers?

A

Text appearing on top of request or response messages showing information about the HTTP message

130
Q

Where would you go if you wanted to learn more about a specific HTTP Header?

A

mdn/HTTP/messages

131
Q

Is a body required for a valid HTTP request or response message?

A

No, responses with a status code that sufficiently answers the request without the need for corresponding payload (like 201 Created or 204 No Content) usually don’t.

132
Q

What is AJAX?

A

A technique for loading data into a part of a page without having to refresh the entire page

133
Q

What does the AJAX acronym stand for?

A

Asynchronous JavaScript and XML

134
Q

Which object is built into the browser for making HTTP requests in JavaScript?

A

XMLHttpRequest

135
Q

What event is fired by XMLHttpRequest objects when they are finished loading the data from the server?

A

load

136
Q

Bonus Question: An XMLHttpRequest object has an addEventListener() method just like DOM elements. How is it possible that they both share this functionality?

A

The each share the prototype method (hidden 4 levels into the prototype chain)

137
Q

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

A

A section of code contained between {curly braces}

ex/ the code that is run after after a for loop statement

138
Q

What does block scope mean?

A

It means that the variable that is declared is only visible within the code block

139
Q

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

A

Block scope

140
Q

What is the difference between let and const?

A

Variables declared with let are mutable, const variables are not

141
Q

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

A

Because the value stored in an array variable is the address in which it is pointing to therefore the elements

142
Q

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

A

Let & const if you want the variable to be block scope. Const if you want the variable to be constant/immutable

143
Q

What is destructuring, conceptually?

A

It is a way to fetch elements stored inside of an array or object

144
Q

What is the syntax for Object destructuring?

A

The object variable on right side of assignment operator (=)
const, then the variables to store that data on left side inside curly braces
If variables do not share the same property names, you need to put the variable names on right side of property name separated by a colon

145
Q

What is the syntax for Array destructuring?

A

The array variable on right side of assignment operator (=)

const, then the variables to store the array elements on left side inside square brackets

146
Q

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

A

When destructuring, the object/array is on the right side of the assignment operator (=)

147
Q

What is the syntax for writing a template literal?

A

Template literals are surrounded by backticks and an interpolated expressions begin with $ and curly braces around the expression

148
Q

What is “string interpolation”?

A

It is a way to represent strings that are inserted into an expression not defined as a string

149
Q

What is the syntax for defining an arrow function?

A

(param1, param2) => { code block }
If there is only 1 parameter, parentheses are not needed
If code block doesn’t have a statement, curly braces are not needed

150
Q

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

A

It implicitly returns the statement inside of the code block

151
Q

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

A

It doesn’t define its own ‘this’ value but rather it captures the ‘this’ value from the enclosing context

152
Q

What is a CLI?

A

Command Line Interface

153
Q

What is a GUI?

A

Graphical User Interface

154
Q

What are the three virtues of a great programmer?

A

Laziness, impatience, hubris

155
Q

What is Node.js?

A

A JavaScript runtime environment

156
Q

What can Node.js be used for?

A

It can be used to execute JS code outside of a browser

157
Q

What is a REPL?

A

read–eval–print loop
A interactive computer programming environment that allows a single user to input code, execute it and the REPL returns the result

158
Q

When was Node.js created?

A

May 27, 2009

159
Q

What back end languages have you heard of?

A

Express, Django, Flask, Ruby on Rails, PHP, python, perl

160
Q

What is a computer process?

A

An instance of a computer program running

161
Q

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

A

I currently have about 200 process running according to my Task Manager

162
Q

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

A

A full-stack app or program requires multiple processes to work together so understanding processes lets the developer recognize how each piece can perform cohesively and to properly allocated resources to help load balance the server

163
Q

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

A

It is a global object that provides information and control over the current Node.js process

164
Q

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

A

You can handle the process object using its properties

165
Q

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

A

Array of strings

166
Q

What is a JavaScript module?

A

A single JS file

167
Q

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

A

Exports, require, module, __filename, __dirname

168
Q

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

A

Console, process

169
Q

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

A

To export the module into another file. Typically into a file that will use that module

170
Q

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

A

Const variable = require(‘./fileName)

fileName can be written with .js at end, but it is implied

171
Q

What is the JavaScript Event Loop?

A

It is the queue in which messages are ran

172
Q

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

A

Code is blocking if the event loops is being stopped because of that code

173
Q

What is a directory?

A

A folder containing files

174
Q

What is a relative file path?

A

It refers to the location in which a file is found relative to the current directory

175
Q

What is an absolute file path?

A

It refers to the location that contains the root directory

176
Q

What module does Node.js include for manipulating the file system?

A

fs (file system)

177
Q

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

A

fs.writeFile()

178
Q

Are file operations using the fs module synchronous or asynchronous?

A

asynchronous

179
Q

What is a client?

A

A computer or program that sends requests to access services available from servers

180
Q

What is a server?

A

Hardware or software that provides functionality for other programs or devices after a request

181
Q

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

A

GET

182
Q

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

A

HTTP method, request target, HTTP version

183
Q

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

A
Protocol version (usually HTTP/1.1)
Status code (200, 404, 302, etc)
Status text (OK, NOT FOUND, etc)
184
Q

What are HTTP headers?

A

Text appearing on top of request or response messages showing information about the HTTP message

185
Q

Is a body required for a valid HTTP message?

A

No, responses with a status code that sufficiently answers the request without the need for corresponding payload (like 201 Created or 204 No Content) usually don’t.

186
Q

What is NPM?

A

Stands for nose-picking-monkeys

It is a package managing tool by node that allows users to download and install packages to use

187
Q

What is a package?

A

A library of code created by people that are available to be used from npm

188
Q

How can you create a package.json with npm?

A

npm init –yes

189
Q

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

A

A third-party piece of software used to solve a single problem
npm install nameOfPackage

190
Q

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

A

It gets added to the list of “dependencies” in package.json and
A directory holding the dependency is added to ‘node_modules’

191
Q

How do you add express to your package dependencies?

A

Initialize package.json, install express

192
Q

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

A

listen()

193
Q

How do you mount a middleware with an Express application?

A

With app.use() method

194
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

195
Q

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

A

application/json

196
Q

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

A

To clearly indicate the desired action to be performed
But there is little to no significance since the method written is only there for semantics because the code block can be written in any way

197
Q

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

A

It parses incoming requests that are structured as JSON objects.

198
Q

What is PostgreSQL and what are some alternative relational databases?

A

A relational database management system

MySQL, SQL Server, Oracle

199
Q

What are some advantages of learning a relational database?

A

Guarantees data integrity, widely used, portable skill to have

200
Q

What is one way to see if PostgreSQL is running?

A

‘sudo service postgresql status’ or ‘top’

201
Q

What is a database schema?

A

A collection of tables

Sometimes refer to blueprints for building a table

202
Q

What is a table?

A

A set of data elements organized in columns and rows

203
Q

What is a row?

A

A data entry that shows the values for each attribute

204
Q

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

A

It’s a language used to interact with relational databases.

205
Q

How do you retrieve specific columns from a database table?

A

Select “specific column” from “table”

206
Q

How do you filter rows based on some specific criteria?

A

Where (condition)

Like “age” > 10

207
Q

What are the benefits of formatting your SQL?

A

Readability and consistency

208
Q

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

A

=, , !=

209
Q

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

A

At the end of your query, you add “limit x” x is the number of rows to limit

210
Q

How do you retrieve all columns from a database table?

A

Select * from “table”

211
Q

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

A

After: from “table” ⇒ order by “column”

desc for descending order

212
Q

How do you add a row to a SQL table?

A
Use insert into keywords “tableName”
Values keyword (“value1”, “value2”)
213
Q

What is a tuple?

A

A finite ordered list of values

214
Q

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

A

After the values keyword, each tuple is separated by a comma

215
Q

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

A

After the values, use the returning clause

216
Q

How do you delete rows from a database table?

A

‘delete by’ keywords

217
Q

How do you accidentally delete all rows from a table?

A

By omitting the where clause that includes a conditional

218
Q

What is a foreign key?

A

A relational attribute that can be used to join 2 or more tables together

219
Q

How do you join two SQL tables?

A

JOIN “table” USING (“attribute”)

220
Q

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

A

Using an alias with the ‘AS’ keyword

221
Q

What are some examples of aggregate functions?

A

Max, avg, count, sum

222
Q

What is the purpose of a group by clause?

A

To groups a collection of rows to perform aggregate functions on those rows

223
Q

What are the three states a Promise can be in?

A

Pending, fulfilled, rejected

224
Q

How do you handle the fulfillment of a Promise?

A

Call the then() method

225
Q

How do you handle the rejection of a Promise?

A

Call the catch() method