JavaScript Flashcards

1
Q

What is the purpose of variables?

A

To store, represent, and access data via an easily accessible name called an identifier.

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 keyword, or in ES6: let and const keywords.

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

How do you initialize a variable?

A

Using the assignment operator = followed by the value, followed by a semi-colon.

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, dollar sign, or an underscore.

Cannot begin with a number.

Notes: Using the underscore is not very common in JavaScript, but a convention among professional programmers is to use it as an alias for “private (hidden)” variables.

Using the $ is not too common, but professional programmers often use it as an alias for the main function in a JavaScript library or using them for variables holding DOM elements. In jQuery, for instance, the main function $ is used to select HTML elements. In jQuery $(“p”); means “select all p elements”.

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

That changing the case of a letter in a declared variable name will not access the value. The memory address for a variable is assigned to the identifier using the case the declaration was made it. Guidelines state to use camelCase.

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

For storing and manipulating a sequence of characters or text

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 store and manipulate numerical values and to do math, more precisely 64 bit floating point numbers (up to 15 digits and 17 decimals), positive and negative infinity, and NaN.

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

To find out if an expression or a variable is true or false or when you need a data type that can only have two values, like on and off. Used for comparisons and for decision-making in a program (conditionals).

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 an assignment operator, it assigns 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, math functions or other methods, or changing property values

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

Undefined is the absence of data, no value is assigned, is falsy.
Null is the intentional absence of data, treated as a falsy value. Usually a placeholder for data that later gets created or added.

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 describes the value being logged, it can help with debugging by adding clarity to what you’re looking at and what’s happing in your script.

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

What are the 7 JavaScript primitive data types.

A

string, number, boolean, undefined, null, bigint, and symbol

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

It’s the operation of joining strings together, which can be done with the addition operator or a template literal – or you can cheat with just using a comma between strings, lol.

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

Concatenation, addition, and the unary plus operator converts its operand to Number type.

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

It adds the value to the right of the addition assignment operator to the variable and then assigns the result of the expression to that variable

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

What are objects used for?

A

To store a group of key/value pairs and methods as a single entity, or model, as Duckett describes it.

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

What are object properties?

A

Variables that store some related data about the object, often referred to as key/value pairs.

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

Describe object literal notation.

A

Variable declaration or identifier for the for the object, then wrapped in curly braces, property or keys and values separated by a colon, multiple key/value pairs are separated by commas.

ex: var objectName = {
property: value,
property: value
}

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

Using the delete keyword followed by object.property (or object[‘property’])

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 or bracket notation.

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 lists, usually ordered lists.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
Describe array literal notation.
Variable declaration to store the array in, then wrapped in square brackets, a list of values separated by commas. Ex: var arrayName = [item1, item2, item3];
26
How are arrays different from "plain" objects?
They do not hold custom keys for which the values are paired, rather they are numerically indexed.
27
What number represents the first index of an array?
0
28
What is the length property of an array?
The number of items in an array
29
How do you calculate the last index of an array?
array.length - 1
30
What is a function in JavaScript?
It’s a set of statements that performs a task, like a procedure. Referred to as a power tool, per the reading.
31
Describe the parts of a function definition.
1) A function is defined with the function keyword, 2) An optional function name, 3) then 0 or more parameters wrapped in parentheses, separated by commas 4) Then, the function’s code block wrapped in curly brackets, 5) Which may contain an optional return statement.
32
Describe the parts of a function call.
1) function name 2) optional comma-separated argument list wrapped in parentheses 3) followed by a semi-colon. W3 called this ‘calling from code’.
33
When comparing them side-by-side, what are the differences between a function call and a function definition?
A function definition includes the function keyword (in ES5), optional parameters, and a code block defining what the function does. A function call uses the defined function and includes the arguments you want to pass into the function.
34
What is the difference between a parameter and an argument?
Parameters are placeholders for values that can be passed into a function and are listed inside parentheses in the function declaration. They are usually a variable with a descriptive identifier. They are local variables scoped to a function block. Arguments are the actual values you’re passing into the function and are wrapped by parentheses when you invoke the function.
35
Why are function parameters useful?
They are variables accessible by the function code block and tell us what to pass into a function, and often (not always), the number of arguments to pass in.
36
What two effects does a return statement have on the behavior of a function?
1) Causes the function to produce a value we can use in our program. 2) Exits the code block and prevents any more code past the return statement from being run.
37
Why do we log things to the console?
To assist with debugging and to add clarity to what you’re looking at and what’s happing in your script.
38
What is a method?
It’s a function that’s stored as a property of an object. There are 2 kinds – instance methods and static methods. Instance methods are built-in functions that are typically used on an instance of an object, typically an object you would create, so the method is called on the instance of the created object. Static methods are directly accessible from an object’s constructor and are referenced by the object name and can be invoked without creating an instance of an object. Ex: Math object methods, and Array object methods.
39
How is a method different from any other function?
Methods are directly associated with an object.
40
How do you remove the last element from an array?
.pop(); method ex: array.pop();
41
How do you round a number down to the nearest integer?
Math.floor(); method ex: Math.floor(number)
42
How do you generate a random number?
Math.random(); (kind of) This produced a pseudo-random number from 0 up to, but not including 1.
43
How do you delete an element from an array?
1) You can use the .splice(); method on a specific index and for a number of indexes. 2) You can use the .pop(); method to remove one from the end. 3) You can use the .shift(); method to remove one from the front of an array. 4) You can reassign the length property to delete a number of indexes at the end of an array, but this is very dangerous and should probably be avoided.
44
How do you append an element to an array?
.push(); method ex: array.push('new-item');
45
How do you break a string up into an array?
.split(); method and pass in arguments that define the separator, and a limit of splits (optional). (There is also the Array.from(); method if you want to split each character as a different index.)
46
Do string methods change the original string? How would you check if you weren't sure?
No, strings are immutable. You can check by logging the variable to which the original string was assigned to the console.
47
Roughly how many string methods are there according to the MDN Web docs?
Around 3 static, and 33 instance methods.
48
Is the return value of a function or method useful in every situation?
No, because sometimes the function output is not germane to the task we’re trying to accomplish. For instance, in this exercise, the unshift and push methods return the new length of the array and we may not always care about the new length, but rather care about the index values of the array.
49
Roughly how many array methods are there according to the MDN Web docs?
Around 3 static, and 35 instance methods.
50
What three-letter acronym should you always include in your Google search about a JavaScript method or CSS property?
MDN :)
51
Give 6 examples of comparison operators.
``` >= > <= < === !== == != ```
52
What data type do comparison expressions evaluate to?
Booleans
53
What is the purpose of an if statement?
It checks conditions as true or false, and should the condition(s) be met, the following code block executes.
54
Is else required in order to use an if statement?
No, if you are looking for a condition to evaluate to true, the only other else is false, and therefore is not needed.
55
Describe the syntax (structure) of an if statement.
1) If keyword, 2) Followed by a condition wrapped in parentheses, 3) Followed by a code block to execute if the condition is met wrapped in curly braces.
56
What are the three logical operators?
1) && (AND) 2) || (OR) 3) ! (NOT)
57
How do you compare two different expressions in the same condition?
Using the logical AND or OR operators.
58
What is the purpose of a loop?
To repeatedly check conditions and perform the same set of steps (run a code block or statement) until the condition evaluates false. NOTE: A do...while loop will always run once, even if the condition evaluates to false.
59
What is the purpose of a condition expression in a loop?
To tell the loop when to run and when to stop.
60
What does "iteration" mean in the context of loops?
It’s referring to the repetition each time the code is run, each loop.
61
When does the condition expression of a while loop get evaluated?
It’s evaluated before executing the statement, or the code block, every loop.
62
When does the initialization expression of a for loop get evaluated?
It’s evaluated first, before anything else, and only gets evaluated once. Typically used to initialize a counter variable.
63
When does the condition expression of a for loop get evaluated?
After the initialization expression on the first loop, and before each loop iteration and If omitted, the condition always evaluates to true.
64
When does the final expression of a for loop get evaluated?
At the end of each loop iteration, before the next condition check. Used to update or increment the counter variable.
65
Besides a return statement, which exits its entire function block, which keyword exits a loop before its condition expression evaluates to false?
Break keyword.
66
What does the ++ increment operator do?
Increments the counter variable by 1, it’s the same +=1
67
How do you iterate through the keys of an object?
Using a for…in loop. Arrays are for…of loops.
68
What is a "model"?
It is a representation or recreation of something, in this case html recreated as nodes and objects
69
Which "document" is being referred to in the phrase Document Object Model?
The HTML document.
70
What is the word "object" referring to in the phrase Document Object Model?
JavaScript Object
71
What is a DOM Tree?
It is a model of a webpage, and is constructed out of four main types of nodes, the document node, element nodes, attribute nodes, and text nodes.
72
Give two examples of document methods that retrieve a single element from the DOM.
.querySelector() | .getElementByID()
73
Give one example of a document method that retrieves multiple elements from the DOM at once.
.getElementsByClassName() -extra- .getElementsByTagName() .querySelectorAll()
74
Why might you want to assign the return value of a DOM query to a variable?
To access and manipulate the return value, especially if you need it more than once
75
What console method allows you to inspect the properties of a DOM element object?
Console.dir - displays an interactive list of the properties of the specified JavaScript object. The output is presented as a hierarchical listing with disclosure triangles that let you see the contents of child objects. In other words, console.dir() is the way to see all the properties of a specified JavaScript object in console by which the developer can easily get the properties of the object.
76
Why would a script tag need to be placed at the bottom of the HTML content instead of at the top?
In order for the browser to parse the HTML first, then the script can access the HTML elements. Any time you want to access the DOM and use JavaScript to manipulate it, we must add the script tag at the bottom of the body.
77
What does document.querySelector() take as its argument and what does it return?
It takes a CSS selector (in string form) as it’s argument. It returns the first Element within the document that matches the specified selector, or group of selectors. If no matches are found, null is returned.
78
What does document.querySelectorAll() take as its argument and what does it return?
It takes a selector (in string form) as the argument. | It returns a NodeList representing a list of the document's elements that match the specified group of selectors.
79
What is the purpose of events and event handling?
Events are fired to notify code of "interesting changes", and have your script do something in response to the event. Handling events allows you to execute specified code on a specified element at the time of the event.
80
Are all possible parameters required to use a JavaScript method or function?
No, not always. They can be optional.
81
What method of element objects lets you set up a function to be called when a specific type of event occurs?
.addEventListener()
82
What is a callback function?
A function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action.
83
What object is passed into an event listener callback when the event fires?
The event object.
84
What is the event.target? If you weren't sure, how would you check?
It is the element that the event is bound to. You can check by console logging the target property of the event object. In general targets are objects that can receive events and may have listeners for them. Element, and its children, as well as Document and Window, are the most common event targets.
85
Where could you get more information about the event.target?
In the console, in the target property of the event object. Target is an object that has it’s own set of properties.
86
``` What is the difference between these two snippets of code? element.addEventListener( 'click', handleClick ) element.addEventListener( 'click', handleClick() ) ```
The second is an IIFE – it is immediately invoked without parameters, so for this example, as soon as the JS is parsed by the browser, the function tries to run but the event is then undefined.
87
What is the className property of element objects?
The className property of the Element interface gets and sets the value of the class attribute of the specified element.
88
How do you update the CSS class attribute of an element using JavaScript?
By using the .className property of the desired element, and reassigning the value to a different class string,
89
What is the textContent property of element objects?
It represents the text content of the node and its descendants, and allows you to collect or update the just the text that’s in the containing elements (and it’s children).
90
How do you update the text within an element using JavaScript?
By using the .texContent property of the desired element and reassigning the value to a different string.
91
Is the event parameter of an event listener callback always useful?
No, it's not always needed, and we might not reference it.
92
Would this assignment be simpler or more complicated if we didn’t use a variable to keep track of the number of clicks?
More difficult due to the amount of times we have to reference the number of clicks and place conditions on the quantity.
93
Why is storing information about a program in variables better than only storing it in the DOM?
To easily access them a number of times and to add clarity to the code.
94
What event is fired when a user places their cursor in a form control?
Focus event
95
What event is fired when a user's cursor leaves a form control?
Blur event
96
What event is fired as a user changes the value of a form control?
Input event
97
What event is fired when a user clicks the "submit" button within a ?
Submit event
98
What does the event.preventDefault() method do?
Any default action normally triggered as a result of the event will not occur.
99
What does submitting a form without event.preventDefault() do?
It sends the form, and reloads the page
100
What property of a form element object contains all of the form's controls.
.elements property
101
What property of a form control object gets and sets its value?
Value property is the property used by inputs to get and set values.
102
What is one risk of writing a lot of code without checking to see if it works so far?
That nothing works in the end and you don't know where the potential error occurred. It’s also the same risk as moving code around in your page.
103
What is an advantage of having your console open when writing a JavaScript program?
To see what’s happening in the program, when things are or aren't firing, and to test things in the console to make sure they are doing what you expect.
104
Does the document.createElement() method insert a new element into the page?
No, appendChild() method inserts the element into the page.
105
How do you add an element as a child to another element?
You call the appendChild() method on the parent object with the child as the method's argument.
106
What do you pass as the arguments to the element.setAttribute() method?
The attribute name and the attribute value, separated by a comma.
107
What steps do you need to take in order to insert a new element into the page?
You need to first create the element with the createElement() method, then you can optionally set that element’s attribute(s) using the setAttribute() method, then you can optionally create the text content for that element using the .createTextNode() method. Then you need to append the element to it’s parent element in the DOM by using the appendChild() method.
108
What is the textContent property of an element object for?
To get or set the text content of the element.
109
Name two ways to set the class attribute of a DOM element.
1) The .className() property of the Element interface gets and sets the value of the class attribute of the specified element. 2) The .setAttribute() method sets the value of an attribute on the specified element. If the attribute already exists, the value is updated; otherwise a new attribute is added with the specified name and value.
110
What are two advantages of defining a function to do create something (like the work of creating a DOM tree)?
1) Saves time manually entering all the code for the same procedure with different data, piece by piece, instead, you can reuse the function. 2) Easier to read what's happening in the code.
111
What is the event.target?
The object that the event is bound to, or dispatched from.
112
Why is it possible to listen for events on one element that actually happen to its descendent elements?
Because bubbling allows us to move outward from most specific (child) to less specific (parent).
113
What is 'this' in JavaScript?
It's an implicit parameter, meaning that 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. If there is no value to the left of the dot when the function is called, then by default, this will be the global window object.
114
What does it mean to say that 'this' is an "implicit parameter"?
The parameter is available in a function's code block even though it was never included in the function's parameter list or declared with var. It doesn’t need to be explicitly stated.
115
When is the value of this determined in a function; call time or definition time?
Call time.
116
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); } }; ```
*this* refers to the character object.
117
``` var character = { firstName: 'Mario', greet: function () { var message = 'It\'s-a-me, ' + this.firstName + '!'; console.log(message); } }; ``` Given the above character object, what is the result of the following code snippet? Why? character.greet();
“It’s-a-me, Mario!” because this is referencing the object’s property firstName which has a value of ‘Mario’.
118
``` var character = { firstName: 'Mario', greet: function () { var message = 'It\'s-a-me, ' + this.firstName + '!'; ``` Given the above character object, what is the result of the following code snippet? Why? ``` var hello = character.greet; hello(); ```
this.firstName will return undefined, because it’s in the lexical scope of the window.
119
How can you tell what the value of this will be for a particular function or method definition?
If you cannot see the function being called, then you do not know what the value of this will be.
120
How can you tell what the value of this is for a particular function or method call?
* The value of this can be recognized as "the object to the left of the dot" when the function is called (as a method). * If there is no value to the left of the dot when the function is called, then by default, this will be the global window object.
121
What is a method?
A method is a function which is a property of an object. NOTE: There are two kind of methods: Instance Methods which are built-in tasks performed by an object instance, or Static Methods which are tasks that are called directly on an object constructor.
122
How can you tell the difference between a method definition and a method call?
A method is defined as an anonymous function inside an object literal as the value to a key, where a method call passes in arguments and is called with dot or bracket notation on the object.
123
Describe method definition syntax (structure).
An object literal is assigned to a variable, and within the object, an anonymous function with any number of parameters is assigned as a property’s value.
124
Describe method call syntax (structure).
The object name, dot (or bracket), property name which has the method as its value, followed by arguments wrapped in parentheses.
125
How is a method different from any other function?
A method is a property of an object with a function as it’s value, and a function can live on it’s own. A method must be called with the name of it’s object, and a function can be called directly by its name.
126
What is the defining characteristic of Object-Oriented Programming?
Objects can contain both data (as properties) and behavior (as methods).
127
What are the four "principles" of Object-Oriented Programming?
* Abstraction * Encapsulation * Inheritance * Polymorphism
128
What is "abstraction"?
The concept of being able to work with (possibly) complex things in simple ways, an overall generalization of a process or procedure.
129
What does API stand for?
Application programming interface
130
What is the purpose of an API?
Creates a connection between computers and/or between computer programs, allows programmers a way to interact with a system in a simplified, consistent fashion.
131
When does the ‘beforeunload’ event fire on the window object?
When the window, the document, and its resources are about to unload – when you reload the page.
132
What data type can localStorage save in the browser?
A storage object
133
How do you retrieve data from localStorage?
Calling the .getItem() method on the keyname of the item.
134
How do you store data in localStorage?
Calling the .setItem() method on the data (keyName, keyValue).
135
What is JSON?
JSON, or JavaScript Object Notation, is a text-based data format following JavaScript object syntax for serializing objects, arrays, numbers, strings, Booleans, and null. It is commonly used for transmitting data in web applications and computer systems
136
What are serialization and deserialization?
Serialization: converting a native object to a string so it can be transmitted across the network. Deserialization: Converting a string to a native object
137
Why are serialization and deserialization useful?
Because they allow for an object or data structure to be translated into a format that can be sent over a network or storage and then be converted back to the object or data structure.
138
How do you serialize a data structure into a JSON string using JavaScript?
Calling the JSON.stringify() method on the object you want to serialize.
139
How do you deserialize a JSON string into a data structure using JavaScript?
Calling the JSON.parse() method on the string you want to deserialize.
140
What is a "callback" function?
A callback function is a function passed into another function as an argument, which is then invoked inside the outer function to complete some kind of routine or action.
141
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?
Use the setTimeout() function with a delay, or the setInterval() function with a delay.
142
How can you set up a function to be called repeatedly without using a loop?
Use the setInterval() function.
143
What is a code block? What are some examples of a code block?
Code blocks are denoted by curly braces {}, (when not being used for an object literal) for example, the code after a for or while loop, an if, else statement, etc.
144
What does block scope mean?
It means that if a variable is declared in block scope that the declared value is only accessible within that code block and cannot be accessed outside of the code block, that variable is not attached to the global object as a property.
145
What is the scope of a variable declared with const or let?
Block scope
146
What is the difference between let and const?
A variable declared with let can be reassigned different values. However, a variable declared with const is immutable, meaning you cannot reassign the value, it creates a read-only reference to a value.
147
Why is it possible to .push() a new value into a const variable that points to an Array?
Because the value of the variable is a reference to the array, and the array that’s referenced isn’t changing, only its contents.
148
How should you decide on which type of declaration to use, between let and const?
Base it on whether or not you are going to modify the variable, if you are going to modify the variable, then use let, if you are never going to modify the value of the variable, use const.
149
What is destructuring, conceptually?
Destructuring provides an alternative way to assign properties of an object to variables.
150
What is the syntax for Object destructuring?
let { property1: variable1, property2: variable2 } = object; If the variables have the same names as the properties of the object, you can make the code more concise as follows: let { firstName, lastName } = person;
151
What is the syntax for Array destructuring?
const [ firstIndex, secondIndex ] = array; Could also use rest operator for reaming indexes: const [ firstIndex, secondIndex, …indexes ] = array;
152
How can you tell the difference between destructuring and creating Object/Array literals?
When you create an object or array, you assign the array or object literal to the identifier, in destructuring, you assign the objects reference identifier to the property variables. The syntax is essentially flipped on either side of the assignment operator.
153
What is the syntax for defining an arrow function?
``` const funcName = a => a * a -or- const complexFuncName = (a, b, c) { ~return more complex code here~ } ``` Let or const, the function name (optional) the assignment operator, the parameters wrapped in parentheses if more than one, also optional (empty parentheses if none) and the arrow (equals and greater than symbol), then if your code block is a simple expression, you can omit the curly braces and return statemtn, but if it’s a statement, wrap the code in curly braces and use the return statement.
154
When an arrow function's body is left without curly braces, what changes in its functionality?
Whatever follows the arrow is immediately returned – with curly braces, we need a return statement.
155
How is the value of this determined within an arrow function?
It is dependent upon it’s lexical scope. It doesn’t have it’s binding to this. An arrow function captures the this value of the enclosing context instead of creating its own this context. In an arrow function this is determined at definition time. In a regular function, this is determined at call time, the obj attached to the method. If ‘this’ is determined properly, then any reference to this using an arrow function inside the parent function, it’ll take the previous reference. Regular functions will redefine this, arrow function do not. Arrow functions will take on this when it’s called.
156
What is Node.js?
An asynchronous event-driven JavaScript runtime program that *allows JavaScript to be run outside of a web browser.* It is powered by V8 engine; the same JavaScript engine in the Google Chrome browser. It is free, open-source software and its source code is available on GitHub.
157
What can Node.js be used for?
Node.js is designed to build scalable network applications, it is commonly used to build back ends for Web applications, command-line programs, or any kind of automation that developers wish to perform.
158
What is a REPL?
Read–eval–print loop. AKA an interactive toplevel or language shell, - a simple interactive computer programming environment that takes single user inputs, executes them, and returns the result to the user; a program written in a REPL environment is executed piecewise. Ex: the console, a terminal, etc.
159
When was Node.js created?
The initial release was in 2009, authored by Ryan Dahl.
160
What back-end languages have you heard of?
Ruby, Python, .Net or C#, Java, PHP, Node, Rust, Go
161
What is a CLI?
A command-line interface (CLI) processes commands to a computer program in the form of lines of text, like git, or a terminal.
162
What is a GUI?
A graphical user interface. They allow users to interact with electronic devices through graphical icons rather than text-based user interfaces. Examples of GUIs include VS Code, the browser, our operating system, Microsoft Word, or any application we use on our computers.
163
``` Give at least one use case for each of the commands listed below: o man o cat o ls o pwd o echo o touch o mkdir o mv o rm o cp ```
o man – to look up what a command does and how to use it. o cat – print the text content of a file to quickly see what the contents are, or to add the contents of two files together. o ls – to quickly list what’s in a directory (ls stands for list segments) o pwd – to print the name of the current working directory – see where you currently are. o echo – to display a line of text – could use it to send string(s) to a file. o touch – to create or update files. o mkdir – to make a directory without needing to do it in the file explorer. o Mv – to rename a directory. o Rm – to delete a file or directory without needing to do it in the file explorer. o Cp – copy the contents of a file to use them in another file.
164
What are the three virtues of a great programmer?
Hubris, impatience, and laziness.
165
What is the syntax for writing a template literal?
In ES6, you create a template literal by wrapping your text in backticks (`) and to instruct JavaScript to substitute a variable and expression, you wrap the variable and expression in curly braces following a dollar sign ($). Ex: `Hi, my name is ${nameVaraibale}.’
166
What is "string interpolation"?
The ability to substitute part of the string for the values of variables or expressions.
167
What is deadlocking?
A deadlock occurs when 2 processes are competing for exclusive access to a resource but is unable to obtain exclusive access to it because the other process is preventing it. This results in a standoff where neither process can proceed. The only way out of a deadlock is for one of the processes to be terminated.
168
What is a computer process?
a process is the instance of a computer program in execution, that is being executed by one or many threads or set of sequential instructions. (In computer science, a thread of execution is the smallest sequence of programmed instructions that can be managed independently by a scheduler, which is typically a part of the operating system.). It contains the program code and its activity. Depending on the operating system (OS), a process may be made up of multiple threads of execution that execute instructions concurrently. While a computer program is a passive collection of instructions typically stored in a file on disk, a process is the execution of those instructions after being loaded from the disk into memory.
169
Roughly how many computer processes are running on your host operating system (Task Manager or Activity Monitor)?
On PC - ~300 including windows processes. On Mac - ~500
170
Why should a full stack Web developer know that computer processes exist?
Because full stack web development is based on making multiple processes work together to form one application, front-end processes, server processes, and database processes using APIs.
171
What is the process object in a Node.js program?
The process object is a global object that provides information about, and control over, the current Node.js process.
172
How do you access the process object in a Node.js program?
Using the process variable. More precisely, by logging the process object in the js file and in the terminal, in the correct directory, using the node command followed by the file name.
173
What is the data type of process.argv in Node.js?
It is an array (object)
174
What is a JavaScript module?
In JavaScript, a "module" is a single .js file, which contains code for a specific task. Breaking up code into multiple files helps things stay organized and isolated.
175
What values are passed into a Node.js module's local scope?
``` The parameters in the function wrapper: (function(exports, require, module, __filename, __dirname) { // Module code actually lives in here }); ``` The five parameters: exports, require, module, __filename, __dirname
176
Give examples of truly global variables in a Node.js program.
Process, Buffer, and global
177
What is the purpose of module.exports in a Node.js module?
To access the functionality or code from another file or module with a simplified variable while potentially being able to isolate other non-relevant modules. It instructs the program on which module(s) to utilize when.
178
How do you import functionality into a Node.js module from another Node.js module?
By first assigning the exported module functionality to the exports property, and then on the importing module, call the require method of the module object with the exported file path as a string and assign that to a variable which can then be utilized to import the exported functionality.
179
What is a client?
A client is a computer, server, program, etc., that initiates communication with servers by making content or service requests via HTTP messages. A client usually doesn’t share any of its resources.
180
What is a server?
An HTTP server waits for incoming client requests and serves or responds to the client based on the requested data. A server shares its resources with clients. Servers are classified by the services they provide, e.g. file server, or web server.
181
Which HTTP method does a browser issue to a web server when you visit a URL?
The GET Method.
182
What is on the first line of an HTTP request message?
The startline, which contains the HTTP Method, the request target (URL, absolute path, etc), and the HTTP version.
183
What is on the first line of an HTTP response message?
The status line which contains the HTTP version, the status code (like 200 or 404), and the status text (like OK, or Not Found).
184
What are HTTP headers?
An optional second part of a request, specifying the request, or describing the body included in the message, each formatted as a case-insensitive string followed by a colon (':') and a value whose structure depends upon the header. You can also add custom headers in any key value pair. One common would be authorization token. There are three categories of headers: 1) representational, like Content-Type, 2) request, like user-agent and 3) general, like via or connection.
185
Is a body required for a valid HTTP message?
No the body is optional, but some do contain bodies, such as requests that send data to the server in order to update it: as often the case with POST requests (containing HTML form data).
186
What are the response code categories you can get from an HTTP request?
Informational - 100-199 Successful responses – 200-299 Redirection messages – 300-399 Client error messages – client successfully made it to the server, but the request has some errors. 400-499 Server error messages – 500-599, client successfully communicated, but there is something wrong with the server.
187
How are ES Modules different from CommonJS modules?
They use the export and import keywords, and have 2 different types of exports, rather than using the require function and modules.export object
188
What kind of modules can Webpack support?
CommonJS, ES6, AMD, and others. There are many.
189
What is "syntactic sugar"?
It 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. Usually new syntax that improves the ways we code things to make things easier
190
What is the typeof an ES6 class?
A Function
191
Describe ES6 class syntax
Class keyword then, wrapped in curly braces, an optional constructor and parameters for pre-set properties, followed by the property assignments in curly braces, followed by any method names with parentheses and a code block
192
What is "refactoring"?
Code refactoring is the process of restructuring existing computer code—changing the factoring—without changing its external behavior. Refactoring is intended to improve the design, structure, and/or implementation of the software (its non-functional attributes), while preserving its functionality.
193
What is an ES6 JS class?
A JavaScript class is a blueprint for creating objects. A class encapsulates data and functions that manipulate data. Unlike other programming languages such as Java and C#, JavaScript classes are syntactic sugar over the prototypal inheritance. In other words, ES6 classes are just special functions.
194
What is Webpack?
It is a module bundler and allows you to compile javascript modules by generating a single (or few) files that run the application.
195
How do you add a devDependency to a package?
Npm install --save-dev Examples: - -save-dev webpack, - -save-dev webpack-cli, - -save-dev babel-loader
196
What is an NPM script?
Way to bundle common shell commands, in our case, inside the package.json file. For us it was “build:”: “webpack” You can link any made-up property name to a shell command as a value.
197
How do you execute Webpack with npm run?
Ensure that there is a “build” property with a “webpack” value in the scripts object in package.json file. The type `Npm run build` in the shell.
198
What does fetch() return?
fetch() returns a promise which is fulfilled once the response is available. The promise resolves to the Response object representing the response to your request.
199
What is the default request method used by fetch()?
GET method
200
How do you specify the request method (GET, POST, etc.) when calling fetch?
In the init object as the second argument in the fetch function. fetch('https://jsonplaceholder.typicode.com/users', { method: 'GET' })
201
What is a string?
A primitive data type consisting of a sequence of characters within quotation marks or backticks
202
What is a number?
A primitive data type consisting of integers and floating-point numbers.
203
What is a boolean?
A primitive data type consisting of the logical values true or false.
204
What is null?
A primitive data type that is used as the intentional absence of any value.
205
What is undefined?
A primitive data type indicating the usually accidental absence of value, a variable that has not yet been defined or assigned a value.
206
What is a symbol?
A primitive data type, a built-in object whose constructor returns a unique symbol.
207