JavaScript Flashcards

1
Q

What is the purpose of variables?

A

a container used to store data so that you can use it later

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

How do you declare a variable?

A

using let, const, or var keyword and then giving it a name in camelCase

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

using = e.g.(var x = 2)

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, $ sign, and underscore

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

two variables can have the same name but different values if their first letter is capitalized and uncapitalized

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

used to store and represent text information

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

used to store and represent numerical values and do math

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 for conditional statements since booleans can only return two values, either true or false. Helps the program make a decision.

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

assignment, usually when assigning a value to a variable

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

using the assignment operator again, don’t need to use a var keyword the second time

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 is purposeful emptiness, undefined is not purposeful emptiness. Null is declared by the developer, whereas undefined is declared by the computer.

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

to make it clearer what you’re logging exactly in that line of code

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

Give five examples of JavaScript primitives.

A

string, number, boolean, null, and undefined

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

to join 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

add numbers or concatenate strings

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

takes the variable and add something to it and then reassigns that value to the same variable.

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

Are strings immutable? and what does that mean?

A

yes - you cannot change the content of a string once it’s been created. like changing the middle letter of “cat” from a to o. it will always be a.

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

What are objects used for?

A

used to store multiple pieces of information that are related to eachother

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

What are object properties?

A

individual piece of named data within an object

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

Describe object literal notation.

A

declare object with name, assignment operator, opening curly braces for object then key value pairs separated by a comma, then closing curly braces.

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

How do you remove a property from an object?

A

delete operator

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

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

A

dot notation e.g - obect.text or bracket notation - e.g. object[‘property’] = new value

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

What are arrays used for?

A

to store items in a list of information, the order of the list of information is either extremely important or unimportant

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

Describe array literal notation.

A

variable with the name for the array, assignment operator, opening square bracket, list of items in order by index separated by commas, closing square bracket.

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

How are arrays different from “plain” objects?

A

they have indexes which give their content numerical order

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

What is the length property of an array?

A

.length, measures the amount of items there are in an array

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

How do you calculate the last index of an array?

A

array.length - 1

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

What is a function in JavaScript?

A

a process or set of actions that have been given a name, that you can re-use by using that name.

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

Describe the parts of a function definition.

A

function keyword, name of the function, set of parentheses for parameters, curly brace, lines of code, and return statement.

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

Describe the parts of a function call.

A

function name, parentheses, arguments

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

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

A

a function definition has a code-block and function keyword, whereas a function call doesn’t have either.

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

What is the difference between a parameter and an argument?

A

Parameter acts as a placeholder during the function definition, and the argument is the actual value during the function call.

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

Why are function parameters useful?

A

Allows you to have variance in how your code runs, apply the function to different arguments

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

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

A

returns back a value, as well as stop the function entirely.

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

Why do we log things to the console?

A

for debugging, verification (making sure data is what you think it is)

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

What is a method?

A

function stored as a property of an object

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

How is a method different from any other function?

A

SYNTAX! methods always have . and an object before it, functions do not.

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

How do you remove the last element from an array?

A

.pop()

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

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

A

Math.floor

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

How do you delete an element from an array?

A

.splice(indexStart, deleteCount)

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

How do you append or prepend an element to an array?

A

push or unshift

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

How do you break a string up into an array?

A

.split(where to separate or separator)

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

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

A

strings are immutable and can never be mutated or changed so no. But you can check with console log.

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

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

A

36

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

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

A

no

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

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

A

36

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

Give 6 examples of comparison operators.

A

<, >, ==, <=, >=, !==

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

What is the purpose of an if statement?

A

allows us to make decisions in our code based on the result of the value of the boolean

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

Is else required in order to use an if statement?

A

Not required, but if not included - it would come back as undefined.

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

Describe the syntax (structure) of an if statement.

A

keyword if, parentheses that contains a condition, curly braces w/ code inside

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

What are the three logical operators?

A

&& (and), || (or), ! (not)

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

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

A

using logical operators

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

What is the purpose of a loop?

A

a tool that allows you to run the same process over and over again

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

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

A

to check if the loop should keep going. it stops the loops.

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

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

A

a single repetition of the loop

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

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

A

Before the code block is ran

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

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

A

it runs one time before anything

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

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

A

before each iteration

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

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

A

after each iteration and before the condition

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

What does the ++ increment operator do?

A

increases the value of the variable by 1

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

How do you iterate through the keys of an object?

A

use a for-in loop

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

What is JSON?

A

text-based format data following javascript object syntax, data interchange format

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

What are serialization and deserialization?

A

taking spread out memory, like object, and putting into text like a string. Deserialization is the opposite - taking a string and parsing it into an object. (process of taking things in order, or taking them out of order)

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

Why are serialization and deserialization useful?

A

serialization is useful because it helps put things in order and make it easier to transmit, and deserialization makes it easier to access the data

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

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

A

json.stringify()

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

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

A

json.parse()

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

How do you store data in localStorage?

A

localStorage.setItem(‘keyName’, value you want to assign)

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

How do you retrieve data from localStorage?

A

localStorage.getItem(‘keyName’)

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

What data type can localStorage save in the browser?

A

string

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

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

A

before the page closes

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

What is a method?

A

a function assigned to the property of an object

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

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

A

when calling a method you use dot notation, but when defining it is within an object, and has the following structure. methodname: function ()

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

Describe method definition syntax (structure).

A

an object literal, function name then colon which assigns the function definition

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

Describe method call syntax (structure).

A

object.method(arguments)

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

How is a method different from any other function?

A

theres dot notation on methods, you need to specify which object it’s being called on or pulled from.

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

What is the defining characteristic of Object-Oriented Programming?

A

Objects can contain both data, and behavior.

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

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

A

Abstraction, encapsulation, inheritance, polymorphism

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

What is “abstraction”?

A

making very complicated things seemingly simple. simplify interaction with a procedurally complex problem

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

What does API stand for?

A

Application program interface

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

What is the purpose of an API?

A

allows application to exchange data and functionality easily and securely, using a limited set of tools.

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

What is ‘this’ in JavaScript?

A

the object that you’re currently working with, the code block you’re within

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

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

A

meaning it is available in a function’s code block even though it was never included in the function’s parameter list or declared with var.

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

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

A

call-time, unless the function is currently being used - ‘this’ does not exist.

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

Nothing yet, because a function has not yet been called

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

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

A

the string It’s a-me, Mario! and this is because .greet was called on character and we see that it uses the firstName property, which character has.

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

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

A

undefined, because there’s no object

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

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

A

we don’t know, because there is no value until its being used or called

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

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

A

the object to the left of the dot object.something

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

What kind of inheritance does the JavaScript programming language use?

A

prototype-based

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

What is a prototype in JavaScript?

A

an object with shared behavior or data that can be stored in one place and shared amongst different instances

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

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

A

if they have a prototype

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

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

A

it goes and checks for it in each prototype object

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

What does the new operator do?

A

creates a blank plain javascript object, takes the constructor functions prototype property and puts it on the new object, then we say the newobject within the function when it runs is ‘this’. if nothing is returned - the object created in step one is returned.

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

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

A

.prototype

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

What does the instanceof operator do?

A

gives you the ability to check if a specific object is a variant of a larger type of object. newObject.instanceof(originalObject)

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

What is a “callback” function?

A

a function passed through another function call as an argument

104
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()

105
Q

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

A

setInterval()

106
Q

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

A

0

107
Q

What do setTimeout() and setInterval() return?

A

a positive integer that’s specific to that interval

108
Q

What is AJAX?

A

which initially stood for Asynchronous JavaScript And XML, is a programming practice of building complex, dynamic webpages using a technology known as XMLHttpRequest.

109
Q

What does the AJAX acronym stand for?

A

Asynchronous JavaScript And XML

110
Q

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

A

XML HTTP request

111
Q

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

A

‘load’ event

112
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

prototype

113
Q

What is a client?

A

a piece of software that requests service or tool (initiator of a request)

114
Q

What is a server?

A

a provider of the actual content, server responds to a clients requests

115
Q

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

A

GET

116
Q

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

A

method, request target url, and http version

117
Q

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

A

protocol version (http version), status code, status text

118
Q

What are HTTP headers?

A

additional meta data describing the request or response being made

119
Q

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

A

MDN

120
Q

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

A

No, it’s an optional addition where you can give some additional information.

121
Q

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

A

Code surrounded by curly braces. Ex: if statement, function, for loop

122
Q

What does block scope mean?

A

the block scope restricts the variable that is declared inside to a specific block

123
Q

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

A

block-scope

124
Q

What is the difference between let and const?

A

let can be reassigned, but const cannot be reassigned

125
Q

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

A

a const variable is still mutable if it’s an array or object

126
Q

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

A

if you want to be able to reassign the variable then use let, if you want to keep it constant and not reassign it use const

127
Q

What is the syntax for writing a template literal?

A

with ticks like ` and to put variables in ${} so for example var string = hello ${variable}

128
Q

What is “string interpolation”?

A

At this point, a template literal is just like a better version of a regular JavaScript string. The big difference between a template literal and a regular string is substitutions.

The substitutions allow you to embed variables and expressions in a string. The JavaScript engine will automatically replace these variables and expressions with their values. This feature is known as string interpolation.

129
Q

What is destructuring, conceptually?

A

how to get property values or array elements all in one line

130
Q

What is the syntax for Object destructuring?

A

variable initializer keyword, opening curly brace, key names, closing curly brace, assignment operator, and the object you’re pulling the data from.

const { title, author, libraryID } = book1;

131
Q

What is the syntax for Array destructuring?

A

variable initializer keyword, opening curly brace, indexes separated by commas, closing curly brace, assignment operator, and the array you’re pulling the data from.

const [book3, book4, book5] = library;

132
Q

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

A

if curly braces or square brackets are on left side of assignment operator then you are destructuring

133
Q

What is the syntax for defining an arrow function?

A

initializing keyword and function name, assignment operator, parameters, arrow, then code block

let thisFunction = (parameters) => {}

134
Q

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

A

When you omit the curly braces you don’t need to have a return statement

135
Q

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

A

the parent function of the arrow function determines what this is. Usually this is figured out at the time of the function call, but when it comes to arrow functions it’s when the function is defined.

136
Q

What is a CLI?

A

command-line interface

137
Q

What is a GUI?

A

graphical user interface

138
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 - displays manual
cat - displays text for a file
ls - lists directory contents
pwd - print working directory, tells you which folder you’re in
echo - display line of text
touch - change file timestamps/create file
mkdir - creates a new directory
mv - renames a directory
rm - deletes a file only unless you use -r
cp - copies files an directories

139
Q

What are the three virtues of a great programmer?

A

laziness, impatience, and hubris

140
Q

What is Node.js?

A

an asynchronous event-driven JavaScript runtime

141
Q

What can Node.js be used for?

A

allows you to run JavaScript outside of the browser, it can be used for building the backend

142
Q

What is a REPL?

A

Read - Eval - Print Loop // it will accept individual lines of user input, evaluate those inputs according to a user-defined evaluation function, then output the result.

143
Q

When was Node.js created?

A

2009, by Ryan Dahl

144
Q

What back end languages have you heard of?

A

Ruby, php, python, c++, cc, java, assembly, c#, JavaScript,

145
Q

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

A

The process object is a global object that provides information about, and control over, the current Node.js process. Data model of the node program that’s currently running.

146
Q

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

A

As a global object, it is always available to Node.js applications without using require(). It can also be explicitly accessed using require():

const process = require(‘process’);

147
Q

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

A

an array of arguments

148
Q

What is a JavaScript module?

A

It’s an object thats essentially one .js file

149
Q

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

A

exports, require, module, __filename, __dirname

150
Q

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

A

process & console

151
Q

What is a module wrapper?

A

(function(exports, require, module, __filename, __dirname) {
// Module code actually lives in here
});

152
Q

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

A

to store it in a global-like object that way you’re able to export it to other modules

153
Q

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

A

using require on the Node.js module you wish to export to

154
Q

What is the JavaScript Event Loop?

A

basically an entity that controls what’s being processed by the system, if the stack is empty it will pull things from the task queue

155
Q

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

A

blocking code needs to be executed before moving on to the next one, nonblocking doesnt and can be ran asynchronously. Anything occupying the call-stack is blocking.

156
Q

What is a directory?

A

a special file that lists other files and directories

157
Q

What is a relative file path?

A

relative file path tells you how to get to a file from your current location

158
Q

What is an absolute file path?

A

location of a file from the root directory

159
Q

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

A

fs

160
Q

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

A

writeFile

161
Q

Are file operations using the fs module synchronous or asynchronous?

A

both

162
Q

What is a client?

A

the requestor of the service (a program or device that sends requests to a server)

163
Q

What is a server?

A

the provider of the service (a program or device that receive the request from a client and return an service)

164
Q

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

A

GET

165
Q

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

A

http method, request target, http version

166
Q

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

A

protocol version, status code, status text

167
Q

What are HTTP headers?

A

area of http request or response that passes additional info in metadata about the request or response

168
Q

Is a body required for a valid HTTP message?

A

No

169
Q

What is NPM?

A

a website, package registry, and a CLI

170
Q

What is a package?

A

directory with one or more files, and a package.json

171
Q

How can you create a package.json with npm?

A

npm init –yes

172
Q

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

A

dependency is a piece of software that your software is going to need, you can add it by doing “npm install “software””

173
Q

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

A

updates package.json to include dependency and the package is downloaded from the npm registry to node_modules

174
Q

How do you add express to your package dependencies?

A

npm install express

175
Q

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

A

app.listen()

176
Q

How do you mount a middleware with an Express application?

A

by calling the use method of the app object. app.use();

177
Q

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

A

req and res

178
Q

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

A

application/json

179
Q

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

A

This method is used to parse the incoming requests with JSON body and is based upon the bodyparser. You would need it when you want to receive JSON data and add it to a data model

180
Q

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

A

it defines the action to be performed

181
Q

What is PostgreSQL and what are some alternative relational databases?

A

relational database management system, mySQL, SQL by microsoft, oracle

182
Q

What are some advantages of learning a relational database?

A

theyre often free, and widely used. very important to learn the further you get into your career

183
Q

What is one way to see if PostgreSQL is running?

A

sudo service postgresql status

184
Q

What is a database schema?

A

schema defines the structure of how we’re going to be storing our data

185
Q

What is a table?

A

list of rows, each having the same attributes

186
Q

What is a row?

A

one item in the table - has all the column values.

187
Q

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

A

structure query language, primary way of interacting with relational databases. it’s different because it’s a declarative language

188
Q

How do you retrieve specific columns from a database table?

A

select statement with select keyword, column names in quotes, and separated by commas, then the name of the table you want to get it from.

189
Q

How do you filter rows based on some specific criteria?

A

using where keyword

190
Q

What are the benefits of formatting your SQL?

A

makes it easier to read when your queries get longer

191
Q

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

A

=, !=, <, >

192
Q

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

A

limit keyword followed by a number

193
Q

How do you retrieve all columns from a database table?

A

select * from tablename

194
Q

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

A

order by “column name” desc or ascending

195
Q

How do you add a row to a SQL table?

A

instert into “tablename” (“columnName”, “columnName”)
values (‘values’, ‘values’)
returning *;

196
Q

What is a tuple?

A

a list of values with a specific order

197
Q

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

A

by adding more sets of parentheses for values

198
Q

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

A

returning “columnNames”

199
Q

How do you update rows in a database table?

A

update “actors”
set “firstName” = ‘Baby’,
“lastName” = ‘Yoda’
where “actorId” = 15;

200
Q

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

A

if you don’t, it will update every row in the table

201
Q

How do you delete rows from a database table?

A

delete
from “cities”
where “name” = ‘Pyongyang’
returning *;

202
Q

How do you accidentally delete all rows from a table?

A

Not including where

203
Q

What is a foreign key?

A

a value with a column in one table

204
Q

How do you join two SQL tables?

A

select “firstName”,
“lastName”
from “customers”
join “payments” using (“customerId”)

205
Q

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

A

using “as”

206
Q

What is the purpose of a group by clause?

A

to group rows together so you can apply an aggregate function to a group

207
Q

What are some examples of aggregate functions?

A

count, sum, max, min, avg

208
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.

209
Q

How do you handle the fulfillment of a Promise?

A

promise.then( value => {
console.log(value)
}

210
Q

How do you handle the rejection of a Promise?

A

promise.catch(error => {
console.error(error)
}

211
Q

What is Array.prototype.filter useful for?

A
212
Q

What is Array.prototype.reduce useful for?

A

if you want to access the contents of an array of objects, but you want to do it repeatedly

213
Q

What is Array.prototype.map useful for?

A
214
Q

What is “syntactic sugar”?

A

an alternate syntax that’s meant to be easier to understand

215
Q

What is the typeof an ES6 class?

A

function

216
Q

Describe ES6 class syntax.

A

class ClassName {
constructor(…) {
stuff
}
method name() {
stuff
}

Dont need a constructor unless you have arguments you want to pass in

217
Q

What is Webpack?

A

node.js framework that allows you to bundle your javascript modules

218
Q

How do you add a devDependency to a package?

A

–save-dev

219
Q

What is an NPM script?

A

a way to bundle common shell commands

220
Q

How do you execute Webpack with npm run?

A

npm run build

221
Q

How are ES Modules different from CommonJS modules?

A

not using the require method, using import from. and export using export default

222
Q

What kind of modules can Webpack support?

A

ecmascript, commonjs, AMD modules, aseets, webassembly modules

223
Q

What is React?

A

React is a JavaScript library for building user interfaces.

React is used to build single-page applications.

React allows us to create reusable UI components.

224
Q

What is a React element?

A

React element is the smallest renderable unit available in React. React elements are simple javascript objects

225
Q

How do you mount a React element to the DOM?

A

target the container, then create a root using createRoot, then call the .render method of the root object with the element as the argument that you want to append basically

226
Q

What is Babel?

A

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

227
Q

What is a Plug-in?

A

is a software component that adds a specific feature to an existing computer program. Enables customization.

228
Q

What is a Webpack loader?

A

Loaders are transformations that are applied to the source code of a module. They allow you to pre-process files as you import or “load” them. Thus, loaders are kind of like “tasks” in other build tools and provide a powerful way to handle front-end build steps. Loaders can transform files from a different language (like TypeScript) to JavaScript or load inline images as data URLs

229
Q

How can you make Babel and Webpack work together?

A

by using the babel loader

230
Q

What is JSX?

A

extension of javascript syntax, allows you to write HTML within a JS file.

231
Q

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

A

The JSX code wont work if you dont import it, due to the react.createElement

232
Q

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

A

babel loader, and babelplugin

233
Q

What is a React component?

A

a function with reusable code that returns react elements

234
Q

How do you define a function component in React?

A

by writing a function that will return jsx

235
Q

How do you mount a component to the DOM?

A

target the container, then create a root using createRoot, then call the .render method of the root object with the element as the argument that you want to append basically

236
Q

What are props in React?

A

Props are arguments passed into React components.

237
Q

How do you pass props to a component?

A

Props are passed to components via HTML attributes.

238
Q

How do you write JavaScript expressions in JSX?

A

using curly braces within your JSX

239
Q

How do you create “class” component in React?

A

class CustomButton extends React.Component {
render(props) {
return <button>{this.props.text}</button>;
}
}

240
Q

How do you access props in a class component?

A

this.props.name

241
Q

What is the purpose of state in React?

A

allows us to manage changing data in an application

242
Q

How to you pass an event handler to a React element?

A

through attributes

243
Q

What are controlled components?

A

the component itself is managing the state of the component, everything related to it is being controlled by react

244
Q

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

A

value attribute, and onChange attribute

245
Q

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

A

array.map

246
Q

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

A

a unique identifier, something like an Id

247
Q

What does express.static() return?

A

middleware, a function

248
Q

What is the local __dirname variable in a Node.js module?

A

the name of the current module

249
Q

What does the join() method of Node’s path module do?

A

takes in a series of paths as arguments as combines them into one

250
Q

What does fetch() return?

A

a promise .then()

251
Q

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

A

GET

252
Q

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

A

by adding a method parameter

253
Q

When does React call a component’s componentDidMount method?

A

right after the component is mounted

254
Q

Name three React.Component lifecycle methods.

A

constructor, render, componentDidMount, componentDidUpdate, componentWillMount

255
Q

How do you pass data to a child component?

A

using props