Javascript Flashcards

1
Q

What is the purpose of variables?

A

a way to store values

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 and its name

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

with the assignment operator = then semicolon ;

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

The period, the underscore, and the characters $, #, and @

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

capitalizing letters change the name

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

assign text to a value

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 assign a value a number to manipulate

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

assign a value as either true or false

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

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

use the name with a new value assigned

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 means intentionally left blank and undefined means there is no value assigned

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

so you know what the value your seeing represents

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

Give five examples of JavaScript primitives.

A

undefined , null , boolean , string and number

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

integer value

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

What is string concatenation?

A

adding strings together to combine them

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

addition and concatenation

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 value on the right to the variable on the left

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

What are objects used for?

A

containers for named values

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

What are object properties?

A

names that separate objects from others

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

Describe object literal notation.

A

an array of key:value pairs, with a colon separating the keys and values, and a comma after every key:value pair, except for the last

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

use the delete operator before the object name

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

bracket notation name[‘name2’], and dot notation name.name2

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

What are arrays used for?

A

when you want to store an ordered list of values

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

Describe array literal notation.

A

when you define an array using empty brackets

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

they are ordered

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

how many entries there are in the array

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

you subtract 1 from the length since its index starts at 0

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

What is a function in JavaScript?

A

a block of code designed for a task that can be reused

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

the arguments line and then the code block or body of the function

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

the name of the function and the arguments being passed

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 definition has the word function Infront of it as well as the body or declaration block of what the function is doing.

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

parameter if for the definition and argument is what is being sent to the function when it’s called

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

Why are function parameters useful?

A

they describe what the expected argument is

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 ends the execution of the function and also returns controls what is given back to the calling function

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

so developers can temporally see the output of something

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

What is a method?

A

actions that can be performed on objects

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

a method is associated with an object

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

pop() method

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

floor() method

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() then multiply the result by array length or another value

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

splice()

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

append()

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

split()

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

no, call the original string

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

30-40

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, sometimes you just want the function to preform an action

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

30-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 run code if a condition is met

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

the word if, the condition it parentheses, the code that will run if the condition is met

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, 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

logical operators ( &&, ||)

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 repeat a process 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 define how many iterations the statement will have

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

times code is run

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

after the initialization or after previous loop final expression

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

one time when the loop starts

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

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

A

after the code block

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

What does the ++ increment operator do?

A

adds 1 to the variable

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

How do you iterate through the keys of an object?

A

with a for in statement

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

Why do we log things to the console?

A

so we can check the value of an item in the document

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

What is a “model”?

A

a representation of a proposed structure

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

Which “document” is being referred to in the phrase Document Object Model?

A

HTML

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

What is the word “object” referring to in the phrase Document Object Model?

A

the elements and attributes and text

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

What is a DOM Tree?

A

the elements with the attributes and children branching off

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

Give two examples of document methods that retrieve a single element from the DOM.

A

getElementByID and querySelector

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

Give one example of a document method that retrieves multiple elements from the DOM at once.

A

querySelectorAll

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

Why might you want to assign the return value of a DOM query to a variable?

A

so you don’t have to look for it again

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

What console method allows you to inspect the properties of a DOM element object?

A

.dir

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

Why would a tag need to be placed at the bottom of the HTML content instead of at the top?

A

so it loads all other elements first before inspecting the document

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

What does document.querySelector() take as its argument and what does it return?

A

an element and returns the first one to match the name given

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

What does document.querySelectorAll() take as its argument and what does it return?

A

it returns all elements with the given name

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

Why do we log things to the console?

A

to check the value of a variable throughout the code

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

What is the purpose of events and event handling?

A

so that users can interact with a webpage making it less static

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

Are all possible parameters required to use a JavaScript method or function?

A

no

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

What method of element objects lets you set up a function to be called when a specific type of event occurs?

A

addEventListener

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

What is a callback function?

A

a name that refers back to the definition instead of calling it immediately

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

What object is passed into an event listener callback when the event fires?

A

an event

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

What is the event.target? If you weren’t sure, how would you check? Where could you get more information about it?

A

a reference to an object. check mdn

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

What is the difference between these two snippets of code?

element. addEventListener(‘click’, handleClick)
element. addEventListener(‘click’, handleClick())

A

ones a callback function that doesn’t run the code immediately while the other is calling it right away

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

What is the className property of element objects?

A

it sets the class attribute of the element given

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

How do you update the CSS class attribute of an element using JavaScript?

A

className

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

What is the textContent property of element objects?

A

how you get the value of the text of an element

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

How do you update the text within an element using JavaScript?

A

get the element and assign it with textConent property

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

Is the event parameter of an event listener callback always useful?

A

no

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

Would this assignment be simpler or more complicated if we didn’t use a variable to keep track of the number of clicks?

A

more complicated because you’d have to go through html strings, since html doesn’t have values

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

Why is storing information about a program in variables better than only storing it in the DOM?

A

it make it much easier to make effects since all the information is already there

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

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

A

submit

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

What does the event.preventDefault( ) method do?

A

prevents the event default behavior

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

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

A

elements property

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

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

A

it can be hard to see where the code went wrong

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

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

A

see if the code has any errors or check values

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

Does the document.createElement() method insert a new element into the page?

A

no it just creates it

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

How do you add an element as a child to another element?

A

append or appendChild

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

What do you pass as the arguments to the element.setAttribute() method?

A

the name of the attribute and the value you want it to be

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

What steps do you need to take in order to insert a new element into the page?

A

create the element then append it

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

What is the textContent property of an element object for?

A

to get or set the text for an element

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

Name two ways to set the class attribute of a DOM element.

A

element. className

element. setAttribute

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

What are two advantages of defining a function to do create something (like the work of creating a DOM tree)?

A

you can reuse them and test the easier

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

Give two examples of media features that you can query in an @media rule.

A

width/height, orientation

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

Which HTML meta tag is used in mobile-responsive web pages?

A

viewport meta tag

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

What is the event.target?

A

object the event is on

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

Why is it possible to listen for events on one element that actually happen its descendent elements?

A

event bubbling

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

What DOM element property tells you what type of element it is?

A

.tagName

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

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

A

takes a css selector and returns the closest parent

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

How can you remove an element from the DOM?

A

element.remove()

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

If you wanted to insert new clickable DOM elements into the page using JavaScript, how could you avoid adding an event listener to every new element individually?

A

add it to the parent with and if statement to select correct elements

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

What is the event.target?

A

element where the event occurs

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

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

A

the document treats it like it doesn’t exist

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

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

A

takes a selector as a string and returns true or false

122
Q

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

A

element.getAttribute(‘class’)

123
Q

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

A

when you want to verify a value or see if the code itself will run

124
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

add an event listener for each tab

125
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

it would have multiple conditions for each tab

126
Q

What is JSON?

A

JavaScript Object Notation (JSON) is a standard text-based format for representing structured data based on JavaScript object syntax.

127
Q

What are serialization and deserialization?

A

Serialization: converting complex data (like an object) to string
Deserialization: converting string to object

128
Q

Why are serialization and deserialization useful?

A

Serialization allows from data to be stored in memory. Also makes it easier to transfer data across a network.
Deserialization makes it so that data is easier to interact with.

129
Q

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

A

JSON.stringify( )

130
Q

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

A

JSON.parse()

131
Q

How to you store data in localStorage?

A

localStorage.setItem( ) method

132
Q

How to you retrieve data from localStorage?

A

localStorage.getItem( ) method

133
Q

What data type can localStorage save in the browser?

A

‘String’ type data (local storage needs serialized data )

134
Q

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

A

before the page refreshes

135
Q

What is a method?

A

A method is a function that is a property of an object.

136
Q

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

A

A method definition would have the keyword function and { } for the function code block.
A method call would have the object followed by dot notation, name of method and then ( ).

137
Q

Describe method definition syntax (structure).

A

{ property: function methodName ( [optional parameters] ) {code block }, }

138
Q

Describe method call syntax (structure).

A

object.methodName( )

139
Q

How is a method different from any other function?

A

Needs dot notation or bracket notation. Also a method belongs to an object as a property of the object.

140
Q

What is the defining characteristic of Object-Oriented Programming?

A

Objects can contain BOTH data (as properties) and behavior (as methods)

141
Q

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

A

Abstraction, encapsulation, inheritance , polymorphism

142
Q

What is “abstraction”?

A

making a big problem smaller

143
Q

What does API stand for?

A

Application Programming Interface

144
Q

What is the purpose of an API?

A

Selection of tools (set of code features such as methods, properties, events, and URLS) to make it easier for developers to interact with a software.

145
Q

What is this in JavaScript?

A

‘this’ is an implicit parameter of all JavaScript functions.

146
Q

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

A

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

147
Q

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

A

call time

148
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

149
Q

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

A

Result = “It’s-a-me, Mario!” because ‘this’ refers to the object being called. The object firstName property has the value of Mario.

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

Result = “It’s-a-me, undefined!” because ‘this’ refers to the window (hello is not a property of an object, therefore default object would be the window object). Window object does not have the property firstName so therefore, ‘this.firstName” has the value of undefined.

151
Q

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

A

You can’t. Value of ‘this’ is determined at call time.

152
Q

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

A

By looking to left of the dot (the object).

153
Q

What kind of inheritance does the JavaScript programming language use?

A

JS uses prototype-based inheritance

154
Q

What is a prototype in JavaScript?

A

Prototypes are the mechanism by which JavaScript objects inherit features from one another.

155
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

Due to JS prototypes; models that was created that contain these methods.

156
Q

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

A

From the object’s prototype, if it’s not there then object’s object’s prototype

157
Q

What does the new operator do?

A

The new keyword does the following things:
Creates a blank, plain JavaScript object

Links (sets the constructor of) the newly created object to another object by setting the other object as its parent prototype;

Passes the newly created object from Step 1 as the this context;

Returns this if the function doesn’t return an object.

158
Q

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

A

Prototype property

159
Q

What does the instanceof operator do?

A

It tests to see if the prototype property of a constructor appears anywhere in the prototype chain of an object. Returns a boolean.

160
Q

What is a “callback” function?

A

It is a function passed in through another function as an argument

161
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

Use setTimeout( ) function

162
Q

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

A

setInterval()

163
Q

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

A

0

164
Q

What do setTimeout() and setInterval() return?

A

an id for that function

165
Q

What is a client?

A

Piece of software that is asking a service from something

166
Q

What is a server?

A

The provider of the services to clients

167
Q

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

A

GET

168
Q

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

A

HTTP method; request target; HTTP version

169
Q

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

A

Protocol version; status code; status text

170
Q

What are HTTP headers?

A

Further information about the request or response

171
Q

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

A

mdn

172
Q

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

A

no

173
Q

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

A

A block of code within curly braces { };

Examples: if else, for, do while, while; function code block;

174
Q

What does block scope mean?

A

An area within the block where variables can be referenced

175
Q

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

A
Let = block-scoped;
Const = block-scoped
176
Q

What is the difference between let and const?

A

Const can’t be reassigned while let can.

177
Q

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

A

The value within the array is mutable

178
Q

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

A

If the variable is not going to be reassigned, use ‘const’. If it will be reassigned, then use ‘let’

179
Q

What is the syntax for writing a template literal?

A

Template literals use backticks rather than single or double quotes and the javascript expression is as follows: ${variable}

180
Q

What is “string interpolation”?

A

A process where variables and expressions is embedded in a string. The variable/expression has to be placed in a space block as follows:
${variable_name}

181
Q

What is destructuring, conceptually?

A

Taking the values within the object and assign it to a variable

182
Q

What is the syntax for Object destructuring?

A
let {
property1: variable1,
property2: variable2
} = object; 
or
if the variable is the same name as the property then you just need that name in the brackets
183
Q

What is the syntax for Array destructuring?

A

let [index1, index 2] = array

184
Q

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

A

Destructuring: variable name goes on the right of the assign operator ( let/const { } or [ ] = variable )
Creating: variable name goes on the left of the assign operator ( variable = { } or [ ])

185
Q

What is the syntax for defining an arrow function?

A

(parameters separated by commas) => { code block };

If there is only 1 parameter, the parentheses are not needed. If return is a simple expression, brackets and return keyword can be omitted. Brackets and return keyword are needed for code block if it’s multiline statements.

186
Q

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

A

the body becomes the return value

187
Q

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

A

Arrow functions: value of this is determined at definition time
Regular functions: value of this is determined at call time

188
Q

What is a CLI?

A

Stands for command-line interfaces. CLI processes commands to a computer program in the form of lines of text. The program which handles the interface is called a command-line interpreter or command-line processor.

189
Q

What is a GUI?

A

Stands for graphical user interface. GUI 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.

190
Q

Give at least one use case for man.

A

Systems manual pager. Documentation/manual page for commands

191
Q

Give at least one use case for cat.

A

Concatenate files and print on the standard output

192
Q

Give at least one use case for ls.

A

List information about the FILEs (and the current directory by default)

193
Q

Give at least one use case for pwd.

A

Print the full filename of current working directory

194
Q

Give at least one use case for echo.

A

Echo the STRING(s) to standard output…. Display a line of text

195
Q

Give at least one use case for touch.

A

Change file timestamps/ update the access and modification times of each FILE to the current time.

196
Q

Give at least one use case for mkdir.

A

Make directories (if they do not already exist)

197
Q

Give at least one use case for mv.

A

Move (or rename) files

198
Q

Give at least one use case for rm.

A

Remove files or directories (by default, does not remove directories)

199
Q

Give at least one use case for cp.

A

Copy files and directories

200
Q

What are the three virtues of a great programmer?

A
  1. Laziness: The quality that makes you go to great effort to reduce overall energy expenditure. It makes you write labor-saving programs that other people will find useful and document what you wrote so you don’t have to answer so many questions about it.
  2. Impatience: The anger you feel when the computer is being lazy. This makes you write programs that don’t just react to your needs, but actually anticipate them. Or at least pretend to.
  3. Hubris: The quality that makes you write (and maintain) programs that other people won’t want to say bad things about.
201
Q

What is Node.js?

A

Node.js is a program that allows JavaScript to be run outside of a web browser.

202
Q

What can Node.js be used for?

A

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

203
Q

What is a REPL?

A

REPL also known as Read Evaluate Print Loop is a programming language environment (basically a console window) that takes single expression as user input and returns the result back to the console after execution.

204
Q

When was Node.js created?

A

2009 by Ryan Dahl

205
Q

What back end languages have you heard of?

A

Ruby, PHP, Java, .Net, Python

206
Q

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

A

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

207
Q

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

A

Just reference it. As a global, it is always available to Node.js applications without using require().

208
Q

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

A

An array of Strings

209
Q

What is a JavaScript module?

A

A single .js file

210
Q

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

A

exports, require, module, __filename, __dirname

211
Q

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

A

Process and global

212
Q

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

A

To export code into another module

213
Q

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

A

Require( ) and pass in the relative path of the file as a string

214
Q

What is the JavaScript Event Loop?

A

The Event Loop is a queue of callback functions. Takes the first thing on the callback queue and puts it back on the stack if the stack is empty

215
Q

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

A

Blocking is when the execution of additional JavaScript in the Node.js process must wait until a non-JavaScript operation completes.
Non-blocking methods execute asynchronously.

216
Q

What is a directory?

A

Also called folders

217
Q

What is a relative file path?

A

Relative file path to current directory (doesn’t start with a slash)

218
Q

What is an absolute file path?

A

Absolute path contains the root of element and the complete directory list required to location file. Starts with a slash

219
Q

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

A

The fs (file system) module

220
Q

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

A

writeFile( ) method

221
Q

Are file operations using the fs module synchronous or asynchronous?

A

Both. The ones that are synchronous will have ‘sync’ in the name.

222
Q

What is NPM?

A

NPM is the package manager for the Node JavaScript platform. It puts modules in place so that node can find them, and manages dependency conflicts intelligently.

npm consists of three distinct components:
• the website
• the Command Line Interface (CLI)
• the registry

223
Q

What is a package?

A

A package is a file or directory that is described by a package.json file. A package must contain a package.json file in order to be published to the npm registry.

224
Q

How can you create a package.json with npm?

A

Npm init —yes

225
Q

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

A

Dependency = a pack of code your application depends on

Npm install

226
Q

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

A

Package.json gets updated; makes node_modules folder that includes the package you installed

227
Q

How do you add express to your package dependencies?

A

Npm install express

228
Q

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

A

app.listen(path, [callback])

229
Q

How do you mount a middleware with an Express application?

A

By app.use()

230
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

231
Q

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

A

Application/json

232
Q

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

A

It parses the incoming requests object.

It is needed when you need to parse the request bodies that are JSON.

233
Q

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

A

Is arbitrary. It makes it more specific for the client to show the server what the client is wants to do.

234
Q

What is PostgreSQL and what are some alternative relational databases?

A

PostgreSQL is a powerful, free, open source Relational Database Management System (RDBMS).

Other popular relational databases include MySQL (also free), SQL Server by Microsoft, and Oracle by Oracle Corporation.

235
Q

What are some advantages of learning a relational database?

A

Relational databases are arguably the most widely used kind of database. Many times when developers create a full stack developer, they are using a relational database.

236
Q

What is one way to see if PostgreSQL is running?

A

sudo service postgresql status

237
Q

What is a database schema?

A

A collection of tables is called a schema. A schema defines how the data in a relational database should be organized.

238
Q

What is a table?

A

A table is data that is in a list of rows where rows each have the same set of attributes.

239
Q

What is a row?

A

A single instance of record in that table

240
Q

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

A

SQL is a declarative programming language. In declarative languages, programmers describe the results they want and the programming environment comes up with its own plan for getting those results.

241
Q

How do you retrieve specific columns from a database table?

A

Use the select keyword followed by the name of the column

242
Q

How do you filter rows based on some specific criteria?

A

Use the select and where clause; expression that evaulates to true or false

243
Q

What are the benefits of formatting your SQL?

A

For readability

244
Q

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

A

> < = !=

245
Q

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

A

Keyword limit followed by a number for the number of rows

246
Q

How do you retrieve all columns from a database table?

A

Select *

247
Q

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

A

Keyword order by column name ___ (default is ascending) and if want descending put desc

248
Q

How do you add a row to a SQL table?

A

insert into “name of table to insert to” (“column names separated by commas”)
values (’text values wrapped in single quotes’, number values with literal numbers);

249
Q

What is a tuple?

A

In SQL, a list of values is referred to as a tuple.

250
Q

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

A

Data rows can be batch inserted into a database table by specifying more than one tuple of values, separated by commas

251
Q

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

A

Keyword returning *;

252
Q

How do you update rows in a database table?

A

update “table name”

set “attribute column name” = ‘value’ and no single quotes if it’s a number value

253
Q

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

A

You don’t want to update every row to have the same value (unless that is what you intend to do)

254
Q

How do you delete rows from a database table?

A

Keyword delete from and table name and followed a where clause!!!! If not, the entire table will be deleted

255
Q

How do you accidentally delete all rows from a table?

A

By not specifying where

256
Q

What is a foreign key?

A

Is a set of attributes in a table that refers to the primary key of another table. The foreign key links these two tables.

257
Q

How do you join two SQL tables?

A

Use the join keyword followed by “tableName” followed by using keyword followed by (“foreign key”);

258
Q

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

A

Use as (e.g table_name as alias_name)

259
Q

What are some examples of aggregate functions?

A

max(), avg(), count(), min(), sum(), and every()

260
Q

What is the purpose of a group by clause?

A

Groups only certain rows that the user chooses to perform an action on – apply aggregate functions only on selected rows

261
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.
262
Q

How do you handle the fulfillment of a Promise?

A

Use then( ) method

263
Q

How do you handle the rejection of a Promise?

A

Use then( ) method or catch( ) method

264
Q

What is Array.prototype.filter useful for?

A

The filter() method creates a new array with all elements that pass the test implemented by the provided function.

265
Q

What is Array.prototype.map useful for?

A

The map() method creates a new array populated with the results of calling a provided function on every element in the calling array.

266
Q

What is Array.prototype.reduce useful for?

A

callback function on each element of the array

267
Q

What is “syntactic sugar”?

A

Is syntax within a programming language that is designed to make things easier to read or to express.

It makes the language “sweeter” for human use: things can be expressed more clearly, more concisely, or in an alternative style that some may prefer.

268
Q

What is the typeof an ‘ES6 class’?

A

The class declaration is just syntactic sugar of the constructor function, therefore, the result of the ‘typeof’ operator of ES6 class is function.

269
Q

Describe ES6 class syntax.

A

Class keyword followed by curly braces for the class declaration

270
Q

What is “refactoring”?

A

Code refactoring is the process of restructuring existing computer code—changing the factoring—without changing its external behavior; preserve functionality

271
Q

What is Webpack?

A

Is a static module bundler for modern JavaScript applications.

It’s 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.

272
Q

How do you add a devDependency to a package?

A

npm install –save-dev

Or you can manually add it by editing the package.json file and adding an attribute called “devDependencies” that references the name and semantic version of each devDependency

273
Q

What is an NPM script?

A

They are essentially an alias for a command line task that you want to run over and over

An NPM script are typically commands, or a string of commands, which would normally be entered at the command line in order to do something with your application.

274
Q

How do you execute Webpack with npm run?

A

Whatever it’s alias to.

i.e.&raquo_space;> Npm run build

275
Q

How are ES Modules different from CommonJS modules?

A

ES modules are the standard for JavaScript, while CommonJS is the default in Node. js.

276
Q

What kind of modules can Webpack support?

A

ECMAScript modules. CommonJS modules. AMD modules

277
Q

What is React?

A

React is a JavaScript library for building user interfaces.

278
Q

What is a React element?

A

A React Element is what gets returned from components.

It’s an object that virtually describes the DOM nodes that a component represents.

An element is a plain object describing a component instance or DOM node and its desired properties.

279
Q

How do you mount a React element to the DOM?

A

By using ReactDOM.render

280
Q

What is Babel?

A

Babel is a JavaScript compiler

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.

281
Q

What is a Plug-in?

A

A plugin is a software add-on that is installed on a program, enhancing its capabilities.

In computing, a plug-in is a software component that adds a specific feature to an existing computer program. When a program supports plug-ins, it enables customization.

282
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. Loaders even allow you to do things like import CSS files directly from your JavaScript modules!

283
Q

How can you make Babel and Webpack work together?

A

By installing babel loader

284
Q

What is JSX?

A

JSX is an XML-like syntax extension to ECMAScript w/o any defined semantics.

It is called JSX, and it is a syntax extension to JavaScript.
Used to write HTML tags inside JavaScript.

JSX is an XML/HTML-like syntax used by React that extends ECMAScript so that XML/HTML-like text can co-exist with JavaScript/React code

285
Q

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

A

JSX works with React.render() or createElement(); belongs to React

286
Q

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

A

Use babel loader and install the babel-plugin that transforms React JSX

287
Q

What is a React component?

A

Conceptually, components are like JavaScript functions.

Components let you split the UI into independent, reusable pieces.

Think about each piece in isolation.

288
Q

How do you define a function component in React?

A
Function name (props) {
Return (rendered React elements)
}
289
Q

How do you mount a component to the DOM?

A

By using ReactDOM.render

290
Q

What are props in React?

A

They are objects; Props stand for properties; used to pass data between React components

291
Q

How do you pass props to a component?

A

As an argument

292
Q

How do you write JavaScript expressions in JSX?

A

Put them in brackets

293
Q

How do you create “class” component in React?

A
keyword class name keyword extends react.component {
render() {
return the react elements
}
}
294
Q

How do you access props in a class component?

A

this.props

295
Q

What is the purpose of state in React?

A

To keep track of values that will change over time

296
Q

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

A

Pass the event handler to the react React element’s prop

297
Q

What are controlled components?

A

A component who value is controlled by React

298
Q

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

A

Value and onChange

299
Q

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

A

array.map()

300
Q

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

A

an id