JavaScript Flashcards

1
Q

What is the purpose of variables?

A

store date for later use with a name

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

How do you declare a variable?

A

keyword var

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

= sign

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

_$@#1 and letters, cant start with #

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

needs consistency with uppercase/lowercase

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

hold letters/characters

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

What is the purpose of a number?

A

hold numeric values

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

logical value true/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

assign value

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

How do you update the value of a variable?

A

assign it a new value

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 intentional and is assigned/ undefined is not intentional and is not 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 output is for what console log

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, undefined, symbol, bigint

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 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
16
Q

What is string concatenation?

A

joining/combining 2 strings together for a new string

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

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

A

adding 2 values or concatenating

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

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

A

boolean T/F

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

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

A

addition assignment, adds additional info to variable to add to

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

What are objects used for?

A

grouping together variables and functions

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

What are object properties?

A

additional information for the object, name/value, individual keys in an objects

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

Describe object literal notation.

A
var object = {
# = 1
}
declare variable and assign property/value
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

using delete operator then dot notation for object.property

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

bracket notation, dot notation

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

What are arrays used for?

A

store a list of values that are related

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

Describe array literal notation.

A

var name = [ ]

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

hold different amounts of information,
arrays don’t need individual keys
arrays have length property and important to know amount
object not important to know number

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

number of items 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

using the length property then subtracting one

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 set of statements to perform tasks with related inputs and outputs and reuseable
are objects

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

The function keyword to begin the creation of a new function.
An optional name.
A comma-separated list of zero or more parameters, surrounded by () parentheses.
The start of the function’s code block, as indicated by an { opening curly brace.
An optional return statement.
The end of the function’s code block, as indicated by a } closing curly brace.
a set of inputs, a set of outputs, and a rule that relates the elements

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

The function’s name.
A comma-separated list of zero or more arguments surrounded by () parentheses.
Our sayHello function does not take any 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
definition doesn't return anything but calling the function does
code block
function keyword
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 is a placeholder
argument is the value
recipe vs ingredients

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

Why are function parameters useful?

A

to give the function values, varying results

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

Causes the function to produce a value we can use in our program.
Prevents any more code in the function’s code block from being run.

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

to check the result of the code and to make sure everything is working

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

What is a method?

A
In JavaScript functions themselves are objects, so, in that context, a method is actually an object reference to a function.
A method is a function which is a property of an object.
function stored in a property
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

a method is associated with an object property, while a function is 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

random method

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

splice(start, deleteCount)

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

How do you append an element to an array?

A

push–end

unshift-beginner

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

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

no, you can log it

strings are immutable

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

over 40

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 if there are additional methods/functions after

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

over 40

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

evaluates a condition

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

no

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

if keyword
( ) arguments
{ } code block

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

What are the three logical operators?

A

&& logical 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

use the logical operator

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 sequence of instructions that is continually repeated until a certain condition is met in computer programming
repeat a block of code automatically

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 see if the loop should run

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 process wherein a set of instructions or structures are repeated in a sequence a specified number of times or until a condition is met.
set of expressions
Means how many times the loop will 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 each iteration

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

once before the loop begins

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 the iteration after initialization

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

at the end of every iteration
before the next evaluation of condition
after code block runs

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

adds one to the operand
and reassigns
substitutes value

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

for … in loop statement

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

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

A

the target object/element

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

Why do we log things to the console?

A

check functionality and remove potential bugs

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

What is a “model”?

A

representation of something

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

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

A

the HTML document

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

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

A

the elements

the data type object

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

What is a DOM Tree?

A

a model of the webpage

connects parent elements and children nodes

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

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

A

get elements by id

*query selector

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

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

A

query selector all

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

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

A

to make it easier for the browser to look for

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

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

A

console.dir( )

directory

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

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

A

Because the browser needs to go through all the HTML elements before the JavaScript code can access it.

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

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

A

the css selector

* The first element within the document that matches the selector or null

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

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

A

A css selector (universal, type, class, id or attribute) and it returns a Node List with all the properties of that selector.

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

Why do we log things to the console?

A

to check functionality

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

What is the purpose of events and event handling?

A

for user interactions

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

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

A

no, there are functions with no parameters

optional parameters

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

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

A

add event listener ( )

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

What is a callback function?

A
A function that takes another function as parameter and is not called by us.
function definition being passed around with value
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
87
Q

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

A

the event object

all the data of the event that occurred

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

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

A

It is the elements that was interacted with. MDN.

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

What is the difference between these two snippets of code?

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

A

first is a callback function

second is just a separate function

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

What is the className property of element objects?

A

Property of DOM element that gets and sets the className of an element.

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

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

A
using the class name
var cName = elementNodeReference.className;
elementNodeReference.className = cName;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
92
Q

What is the textContent property of element objects?

A

Property that gets and sets the text content of an element and child

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

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

A

query the class

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

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

A

query the element

text content property

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

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

A

no, it is not always used

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

a lot more complicated

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

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

A

Because storing DOM locations in a variable prevents the browser from looking for the information.
easier for javascript to work with

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

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

A

submit

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

What does the event.preventDefault() method do?

A

It prevents the default event functionality from being fired from happening.

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

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

A

automatically reloads the form

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

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

A

.value property

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

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

A

there could be bugs that could have been prevented

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

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

A

debugging

seeing events

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

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

A

no

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

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

A

. appendChild ( )

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

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

A

the attribute name and attribute value

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

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

A

create the element then append the element to the document

112
Q

What is the textContent property of an element object for?

A

Property thats gets and sets the text content of an element.

113
Q

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

A
set Attribute ( )
className method
114
Q

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

A

automation and so you don’t repeat yourself

115
Q

2 things

A

create elements from DOM

create function to call elements

116
Q

What is the event.target?

A

the element that was targeted/interacted with

117
Q

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

A

event bubbling
event flow, the event starts at the most specific node then flows to least specific
occur on parent of parent etc

118
Q

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

A

.tagName property of the element

119
Q

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

A

It takes a selector and return itself or the closest parent that matches the selector.

120
Q

How can you remove an element from the DOM?

A

element.remove ( )

121
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

by adding it to the parent element

122
Q

What is the event.target?

A

The element that triggered event

123
Q

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

A

The element is not displayed and it is removed from the document flow.

124
Q

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

A

A string representing the selector and return a boolean value.

125
Q

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

A

element. getAttribute (‘string’)

126
Q

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

A

every step

127
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

use multiple eventlistener and functions

128
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

with more IF statements

and functions

129
Q

What is JSON?

A

JavaScript Object Notation
strings written in object notation
text based data format to making storing and transferring data easier
data interchange format

130
Q

What are serialization and deserialization?

A

serialization is object to string
deserialization is string to object

Serialization is the process of turning an object in memory into a stream of bytes so you can do stuff like store it on disk or send it over the network.

Deserialization is the reverse process: turning a stream of bytes into an object in memory.

131
Q

Why are serialization and deserialization useful?

A

to make data transferring and storing more efficient

132
Q

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

A

Using JSON.Stringify( )

133
Q

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

A

JSON. parse ( )

134
Q

How to you store data in localStorage?

A

localStorage. setItem ( )
method of the storage interface
key and value

135
Q

How to you retrieve data from localStorage?

A

localStorage. getItem ( )
method of the storage interface
needs the key

136
Q

What data type can localStorage save in the browser?

A

ONLY string values

137
Q

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

A

when the window, the document and its resources are about to be unloaded.

138
Q

What is a method?

A

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

139
Q

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

A

the ( ) after the method
function keyword
the arguments
function code block

140
Q

Describe method definition syntax (structure).

A
  1. Method name:
  2. Function keyword;
  3. Parameters (optional);
  4. Opening curly brace;
  5. Code;
  6. Closing curly brace.
141
Q

Describe method call syntax (structure).Describe method call syntax (structure).

A
  1. Object.
  2. Method name;
  3. Arguments inside parentheses (optional).
142
Q

How is a method different from any other function?

A

It is a function stored inside an object as a property.

143
Q

What is the defining characteristic of Object-Oriented Programming?

A

Objects can contain both data (as properties) and behavior (as methods).

144
Q

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

A

Abstraction
Encapsulation
Inheritance
Polymorphism

145
Q

What is “abstraction”?

A

Using something complex, in a simple way.
generalizing
knowing what something does without how it happens

146
Q

What does API stand for?

A

Application Programming Interface.

147
Q

What is the purpose of an API?

A

a set of functions that allows applications to access data and interact with external software components, operating systems, or microservices.
software abtraction

148
Q

What is this in JavaScript?

A

implicit parameter of all JavaScript functions.

the variable whose value is the object that is executing the function

149
Q

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

A

the value of this is determined at call time.

no parameters

150
Q

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

A

call time

151
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

152
Q

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

A

It’s-a-me, Mario!

153
Q

Given the above character object, what is the result of the following code snippet? Why?

A

It’s-a-me, undefined!

154
Q

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

A

you cannot tell

155
Q

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

A

The value of this will be in relation to who made the call.

The value of “this” will be the object that is calling it.

156
Q

What kind of inheritance does the JavaScript programming language use?

A

Prototype-based programming is a style of object-oriented programming in which classes are not explicitly defined, but rather derived by adding properties and methods to an instance of another class or, less frequently, adding them to an empty object.

In simple words: this type of style allows the creation of an object without first defining its class.
prototypal

157
Q

What is a prototype in JavaScript?

A

A prototype is a model that displays the appearance and behavior of an application or product early in the development lifecycle.
object that other objects can build on

158
Q

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

A

the methods are defined on a prototype object

and are inherited

159
Q

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

A

in the prototype

160
Q

What does the new operator do?

A

The new operator lets developers create an instance of a user-defined object type or of one of the built-in object types that has a constructor function.
The new keyword is used in javascript to create a object from a constructor function. The new keyword has to be placed before the constructor function call and will do the following things:

Creates a new object
Sets the prototype of this object to the constructor function’s prototype property
Binds the this keyword to the newly created object and executes the constructor function
Returns the newly created object

161
Q

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

A

prototype property

162
Q

What does the instanceof operator do?

A

The instanceof operator tests to see if the prototype property of a constructor appears anywhere in the prototype chain of an object. The return value is a boolean value. check the type of an object at the run time.

163
Q

What is a “callback” function?

A

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.
A callback function is a function which is:
accessible by another function, and
is invoked after the first function if that first function completes

164
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( ) function

165
Q

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

A

setInterval( ) function

166
Q

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

A

zero

167
Q

What do setTimeout() and setInterval() return?

A

setTimeout allows us to run a function once after the interval of time.
This works in a very similar way to setTimeout(), except that the function you pass as the first parameter is executed repeatedly at no less than the number of milliseconds given by the second parameter apart
non zero value

168
Q

What is a client?

A

software making use of

party requesting service

169
Q

What is a server?

A

provider of the service or resource

170
Q

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

A

GET method

The browser looks up the IP address for the domain name via DNS. The browser sends a HTTP request to the server.

171
Q

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

A

HTTP/1.1 200 OK
Accept-Ranges: bytes
Age: 2793

The protocol version, usually HTTP/1.1.
A status code, indicating success or failure of the request. Common status codes are 200, 404, or 302
A status text. A brief, purely informational, textual description of the status code to help a human understand the HTTP message.

172
Q

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

A

GET / HTTP/1.1
Accept: /
Accept-Encoding: gzip, deflate

method
request target
HTTP version

173
Q

What are HTTP headers?

A

string followed by a colon (‘:’) and a value whose structure depends upon the header. The whole header, including the value, consist of one single line, which can be quite long.

174
Q

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

A

MDN

175
Q

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

A

no

176
Q

What is AJAX?

A

Asynchronous JavaScript And XML.
Make requests to the server without reloading the page
Receive and work with data from the server
is a programming practice of building complex, dynamic webpages using a technology known as XMLHttpRequest.

177
Q

What does the AJAX acronym stand for?

A

Asynchronous JavaScript And XML.

178
Q

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

A

XMLHttpRequest object

179
Q

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

A

load

180
Q

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

A

shared prototype object

181
Q

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

A

the code that is in between the curly braces of a function
conditions
loops
return

182
Q

What does block scope mean?

A

whatever is in between the code block
what is defined inside the specific block
variable lives and dies within { }

183
Q

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

A

block scoped

184
Q

What is the difference between let and const?

A

Like the let keyword, the const keyword declares blocked-scope variables. However, the block-scoped variables declared by the const keyword can’t be reassigned.
let is mutable
const is immutable

185
Q

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

A

let is mutable
const is not mutable
its not reassignment
value can be changed but not reassigned

186
Q

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

A

depending if you want something to be constant or not

187
Q

What is the syntax for writing a template literal?

A

` text content `
the backticks
string text ${expression} string text

188
Q

What is “string interpolation”?

A

the ability to substitute part of the string for the values of variables or expressions.

189
Q

What is destructuring, conceptually?

A

assigning properties of an object to individual variables.

the process of unpacking a small part of something from the main part.

190
Q

What is the syntax for Object destructuring?

A

let/const/var
{
property Key Name: variable1, property2: variable2
} = object; (destructing)

191
Q

What is the syntax for Array destructuring?

A

keyword
[ element names
]
= deconstructed variable

192
Q

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

A

the object/array would have been assigned already and on the left hand side of the =

193
Q

What is the syntax for defining an arrow function?

A
  • Variable keyword
  • Variable name
  • Parameters(optional with 1 parameter)
  • Arrow =>
  • Bracket (Only required if statement)
    single expression OR code block
194
Q

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

A
  • The function can only have one line of code

- The code block must be an expression (code that resolves to value)

195
Q

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

A
  • The value of this is determined by it’s parent code block (outward with arrow functions)
    lexical scope
    its determined when the function is defined outside of the code block
196
Q

What is a CLI?

A

command line interface
processes commands to a computer program in the form of lines of text.
that accepts text input to execute operating system functions.

197
Q

What is a GUI?

A

graphical user interface
a computer program that enables a person to interact with a computer through the use of symbols, visual metaphors, and pointing devices
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.

198
Q

man

A

an interface to the system reference manuals

199
Q

cat

A

concatenate files and print on the standard output

200
Q

ls

A

list directory contents

201
Q

pwd

A

print name of current/working directory

202
Q

echo

A

display a line of text

203
Q

touch

A

change file timestamps or create a new file

204
Q

mkdir

A

make directories

205
Q

mv

A

move (rename) files

206
Q

rm

A

remove files or directories

207
Q

cp

A

copy files and directories

208
Q

What are the three virtues of a great programmer?

A

laziness, impatience, hubris

209
Q

What is Node.js?

A

an asynchronous event-driven JavaScript runtime
a program executes JavaScript code outside a web browser to make the application faster
usually used in the backend

210
Q

What can Node.js be used for?

A

build back ends for Web applications, command-line programs, or any kind of automation that developers wish to perform. make things faster like netflix or social media
server side and command line programs

211
Q

What is a REPL?

A

A read–eval–print loop (REPL), also termed an interactive toplevel or language shell, is a simple interactive computer programming environment that takes single user inputs, executes them, and returns the result to the use

212
Q

When was Node.js created?

A

May 27, 2009

213
Q

What back end languages have you heard of?

A

node.js, python, ruby, PHP, Java, .Net, C#, perl

214
Q

What is a computer process?

A

a set of instructions currently being processed by the computer processor.
A process is a program that is running on your computer. This can be anything from a small background task
instance of a computer program being executed by one or more threads
instance of a running program

215
Q

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

A

over 500

and 2400 theads

216
Q

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

A

Full stack Web development is based on making multiple processes work together to form one application, so having at least a cursory awareness of computer processes is necessary. This will be extremely important when learning about applications made of multiple components, such as clients, servers, and databases.
web dev is based on making multiple processes work together to form one application

217
Q

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

A

a global object that can be accessed inside any module without requiring it

218
Q

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

A

since its global it can be accessed inside any module without requiring it

219
Q

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

A

array of strings

220
Q

What is a JavaScript module?

A

a single .js file

221
Q

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

A

exports, require, module, __filename, __dirname LOCAL

222
Q

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

A

process, console and global

223
Q

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

A

Module exports are the instruction that tells Node. js which bits of code (functions, objects, strings, etc.) to “export” from a given file so other files are allowed to access the exported code

224
Q

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

A

use the require function keyword at the top of the file then relative url

225
Q

What is the JavaScript Event Loop?

A

the event loop is responsible for executing the code, collecting and processing events, and executing queued sub-tasks
one task at a time to an extent
look at the task queue and pushes it to the stack

226
Q

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

A

blocking assignment takes affect immediately it is processed. A nonblocking assignment takes place at the end of processing the current “time delta”
blocking on the stack, nothing else can happen until it gets popped off
non blocking refers to the task not having asynchronous, off the stack

227
Q

What is a directory?

A

a file system that contains references to other files

type of file that lists other files

228
Q

What is a relative file path?

A

a short hand version of the file url with no root

file path from the current location

229
Q

What is an absolute file path?

A

The url with all the information including the root of the file full URL that goes in href
starts with /

230
Q

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

A

‘fs” module or file module

231
Q

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

A

writeFile method

232
Q

Are file operations using the fs module synchronous or asynchronous?

A

asynchronous writefile and readfile

synchronous writefilesync and readfilesync

233
Q

What is a client?

A

software making use of party requesting service

program/computer that requests access from another program/computer

234
Q

What is a server?

A

provider of the service or resource

program/computer that provides functionality to another program/computer

235
Q

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

A

GET method

The browser looks up the IP address for the domain name via DNS. The browser sends a HTTP request to the server.

236
Q

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

A

GET method

The browser looks up the IP address for the domain name via DNS. The browser sends a HTTP request to the server.

237
Q

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

A

method, target, HTTP version

238
Q

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

A

protocol version, status code, status text

239
Q

What are HTTP headers?

A

let the client and the server pass additional information with an HTTP request or response
meta data for the response or request

240
Q

Is a body required for a valid HTTP message?

A

no, they are optional

241
Q

What is NPM?

A

large Software Registry for users to share and borrow packages
the registry is a large public database of JavaScript software and the meta-information surrounding it.
the website
the Command Line Interface (CLI)
the registry
node package manager

242
Q

What is a package?

A

A package is a file or directory that is described by a package.json file
one or more files with a package.json
packages have a package.json

243
Q

How can you create a package.json with npm?

A

go to the root of your directory

npm init –yes

244
Q

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

A

Packages required by your application in production.

npm install

245
Q

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

A

npm will download dependencies and devDependencies that are listed in package. json that meet the semantic version requirements listed for each.
package was downloaded by the registry in the directory updates the package dependencies in the package.json

246
Q

How do you add express to your package dependencies?

A

create a package.json then install it from the npm registry

npm install express

247
Q

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

A

listen method

app.listen()

248
Q

How do you mount a middleware with an Express application?

A

use method of app object

Middleware functions are functions that have access to the request object (req), the response object (res)

249
Q

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

A

the request object ( req ), the response object ( res )

250
Q

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

A

Content-Type: application/json; charset=utf-8

251
Q

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

A

to parse the incoming requests with JSON payloads and is based upon the bodyparser

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

253
Q

How do you handle the fulfillment of a Promise?

A

then method

254
Q

How do you handle the rejection of a Promise?

A

catch method

255
Q

What is Array.prototype.filter useful for?

A

creating a new array of elements that pass a filter test implemented by the provided function.
filter((element) => { /* … */ } )

256
Q

What is Array.prototype.map useful for?

A
Creating a new array containing the transformed elements of another. 
The map() method creates a new array populated with the results of calling a provided function on every element in the calling array.
map((element) => { /* ... */ })
257
Q

What is Array.prototype.reduce useful for?

A

Combining the elements of an array into a single value.
similar to aggregate
reduce((previousValue, currentValue) => { /* … */ } )
name parameters the value you want
name second parameter element of array

258
Q

What is “syntactic sugar”?

A

syntactic changes in code to make the code more clear and concise

259
Q

What is the typeof an ES6 class?

A

constructor function

260
Q

Describe ES6 class syntax.

A
class Person {
    constructor(name) {
        this.name = name;
    }
    getName() {
        return this.name;
    }
}
class keyword
constructor method to initialize the properties of an instance.
261
Q

What is “refactoring”?

A

restructuring code without changing its behavior

262
Q

What is React?

A

A JavaScript library for building user interfaces for building user interfaces based on UI components.

263
Q

What is a React element?

A

an element in the dom
React elements are plain objects, desribes what you want the DOM to look like

A React element is an object representation of a DOM node or component instance building blocks
an object describing a component instance or DOM node and its desired properties
desribes what you want the DOM to look like

264
Q

How do you mount a React element to the DOM?

A

with the render method of the reactdom object

ReactDOM.render(element, container[, callback])

265
Q

How do you mount a React element to the DOM?

A

ReactDOM.render( )

method

266
Q

What is Babel?

A

a JavaScript compiler
mainly used to convert ECMAScript 2015+ code into a backwards compatible version of JavaScript in current and older browsers or environments

267
Q

What is a Plug-in?

A

a software component(branch of software) that adds a specific feature to an existing computer program

268
Q

What is a Webpack loader?

A
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
A Webpack loader is a node module that applies transformations to the source code to of a module and outputs JavaScript
269
Q

How can you make Babel and Webpack work together?

A

Install all dev dependencies

  • webpack
  • webpack-cli
  • babel-loader
  • @babel/core
  • @babel/plugin-transformation-react-jsx

Configure webpack.config.js file to

  • use babel loader as the loader
  • use plugin transform react jsx

by adding babel-loader to the list of modules in webpack.config

270
Q

What does fetch() return?

A

A promise that resolves to a response object.

a promise for a response

271
Q

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

A

GET

272
Q

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

A

The 2nd argument is going to be an object literal with the property Method then the request method.

273
Q

What must the return value of myFunction be if the following expression is possible?
myFunction()();

A

return of myFunction

returns the function

274
Q
What does this code do?
const wrap = value => () => value;
A

assigns the return of the second function to a variable
wrap is storing a function definition and that definiton is also another function definition
returns the value

275
Q

In JavaScript, when is a function’s scope determined; when it is called or when it is defined?

A

when it is defined

276
Q

What allows JavaScript functions to “remember” values from their surroundings?

A

closures