JavaScript Flashcards

1
Q

What is the purpose of variables?

A

Store data

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

How do you declare a variable?

A

with 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

with the assignment operator (=)

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, Characters, numbers, nonpunctuation characters

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

sensitive to uppercase and lowercase letters

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

What is the purpose of a string?

A

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

For any numeric function

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

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

it assigns a 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

using the dot (.)

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 an assigned value, Undeclared has not been 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

To show you what you are logging

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, null, boolean, undefined

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

What is string concatenation?

A

Adding two or more strings together

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

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

A

to combine

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

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

A

true or false

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

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

A

adds the variable on the right to the left and assigns it back into the variable on the left

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

What are objects used for?

A

to store multiple properties, and to know where the data is, and to use that data together

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

What are object properties?

A

a single value stored on an object

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

Describe object literal notation.

A

var followed by curly braces with properties inside

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

How do you remove a property from an object?

A

the delete operator

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

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

A

with the dot or brackets

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

What are arrays used for?

A

a data structure that stores a collection of data

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

Describe array literal notation.

A

An array literal is a list of zero or more expressions, each of which represents an array element, enclosed in square brackets ( [] ).

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

What is the length property of an array?

A

Calculates the total length of an array

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

How do you calculate the last index of an array?

A

-1

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

Why do we log things to the console?

A

console.log

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

What is a method?

A

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

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

How is a method different from any other function?

A

it is a object reference to a function

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

How do you generate a random number?

A

.random() method

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

How do you delete an element from an array?

A

.splice() method

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

How do you append an element to an array?

A

.push() method

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

How do you break a string up into an array?

A

.split() method

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

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

A

No they dont

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

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

A

No

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

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

A

a lot.

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

Give 6 examples of comparison operators.

A

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

equal, not equal to, strictly equal, strictly inequal, greater than

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

What data type do comparison expressions evaluate to?

A

boolean: true, false

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

What is the purpose of an if statement?

A

it allows your code to execute the statement between the brackets or to go on to the else

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

Describe the syntax (structure) of an if statement.

A

if (condition) {statement} else

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

What are the three logical operators?

A

&&, ||, and ~

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

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

A

==

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

What is the purpose of a loop?

A

To loop throat a a condition until something is executed

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

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

A

to evaluate if something is true or false

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

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

A

the amount of times it repeats

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

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

A

before the loop

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

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

A

at the beginning of the loop

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

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

A

after the initialization

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

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

A

In the return statement

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

Why do we log things to the console?

A

to let us know what we are doing

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

What is a method?

A

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

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

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

A

method definition is going to have everything and a method call is the name of the object.method()

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

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

A
A code block uses curly braces to group zero or more statements. var x = 1;
let y = 1;
if (true) {
  var x = 2;
  let y = 2;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
59
Q

What does block scope mean?

A

Not attached to global scope

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

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

A

Block Scoped

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

What is the difference between let and const?

A

Let is not initialized to any value, Const creates a read-only reference to a value

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

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

A

It allows you to change the arrays elements, however you cannot reassign the array to another array

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

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

A

use let if the variable’s value will change during the code

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

What is the syntax for writing a template literal?

A

use the backtick ( ` ) character

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

What is “string interpolation”?

A

the process of embedding an expression into part of a string.

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

What is destructuring, conceptually?

A

extracting data from arrays or objects

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

What is the syntax for Object destructuring?

A

const { identifier } = expression

68
Q

What is the syntax for Array destructuring?

A

const [ identifier ] = expression

69
Q

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

A

one uses square brackets and the other uses curly braces.

70
Q

What is the syntax for defining an arrow function?

A

variable = () => { }

71
Q

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

A

It has an implicit return

72
Q

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

A

an arrow function captures the this value of the enclosing context instead of creating its own this context

73
Q

What is a CLI?

A

A command line interface

74
Q

What is a GUI?

A

Graphical user interface

75
Q
Give at least one use case for each of the commands listed in this exercise.
man
cat
ls
pwd
echo
touch
mkdir
mv
rm
cp
A
man - opens a manuel
cat - concatenation 
ls - see what files are in a directory
pwd - see where you are in the files system
echo - repeats the string you type in
touch - create a new file or update 
mkdir - make a directory
mv - moving files 
rm - remove files
cp - copying files
76
Q

What are the three virtues of a great programmer?

A

laziness, impatience, hubris

77
Q

What is Node.js?

A

Node.js is an open-source, cross-platform, back-end JavaScript runtime environment that runs on the V8 engine and executes JavaScript code outside a web browser.

78
Q

What can Node.js be used for?

A

web sites and back-end API services

79
Q

What is a REPL?

A

Read–eval–print loop

80
Q

When was Node.js created?

A

2009

81
Q

What back end languages have you heard of?

A

node.js, java, ruby, python, php, c, c++, c#, php, javascript, sql*, go, rust, swift, assembly,

82
Q

What is a computer process?

A

Its a program running on your computer

83
Q

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

A

about 300

84
Q

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

A

To know what processes are running.

85
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

86
Q

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

A

process

87
Q

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

A

an array of strings

88
Q

What is a JavaScript module?

A

a “module” is a single .js file.

89
Q

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

A

__dirname, __filename, module, exports, required

90
Q

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

A

process and console

91
Q

What is a directory?

A

a folder

92
Q

What is an absolute file path?

A

An absolute path always contains the root element and the complete directory list required to locate the file.

93
Q

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

A

fs module

94
Q

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

A

fs writefile

95
Q

What is a client?

A

someone who intiates communication sessions with servers, service requesters

96
Q

What is a server?

A

providers of a resource or service

97
Q

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

A

HTTP GET request

98
Q

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

A

The start line, which describes the request being implemented

99
Q

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

A

A header line with the status code, http version,

100
Q

What are HTTP headers?

A

Meta data, Shows information about the request and the response

101
Q

Is a body required for a valid HTTP message?

A

No, the body is optional

102
Q

What is NPM?

A

npm is a software registry meaning people can share and borrow packages and can use npm to manage private development as well

103
Q

What is a package?

A

A package is a file or directory that is described by a package.json file.

104
Q

How can you create a package.json with npm?

A

npm init –yes

105
Q

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

A

the install command and its

106
Q

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

A

It adds a node-modules directory

107
Q

How do you add express to your package dependencies?

A

install it with npm

108
Q

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

A

listen method

109
Q

How do you mount a middleware with an Express application?

A

call a middleware method, use()

110
Q

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

A

the req and res objects

111
Q

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

A

application/json

112
Q

What is PostgreSQL and what are some alternative relational databases?

A

PostgreSQL is a powerful, free, open source Relational Database Management System (RDBMS). MySQL (also free), SQL Server by Microsoft, and Oracle by Oracle Corporation.

113
Q

What are some advantages of learning a relational database?

A

they support good guarantees about data integrity.

114
Q

What is one way to see if PostgreSQL is running?

A

sudo service postgresql status

115
Q

What is a database schema?

A

A schema defines how the data in a relational database should be organized.

116
Q

What is a table?

A

You might visualize a database table as a sort of spreadsheet where each row is a record in that spreadsheet

117
Q

What is a row?

A

A table is a list of rows each having the same set of attributes.

118
Q

What are the three states a Promise can be in?

A

pending, fulfilled, rejected

119
Q

How do you handle the fulfillment of a Promise?

A

use the then method to return a promise

120
Q

How do you handle the rejection of a Promise?

A

use the catch method to return a promise with rejected cases only

121
Q

What is Array.prototype.filter useful for?

A

For creating a new array with all elements that pass the test implemented b y the provided function

122
Q

What is Array.prototype.map useful for?

A

Creating a new array populated with the results of a calling a provided function on every element in the calling array.

123
Q

What is Array.prototype.reduce useful for?

A

Return the sum of all elements in array by executing a user supplied reducer callback function

124
Q

What is “syntactic sugar”?

A

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

125
Q

What is the typeof an ES6 class?

A

function

126
Q

Describe ES6 class syntax.

A

Class keyword, constructor

127
Q

What is “refactoring”?

A

Restructuring existing code without changing its behavior

128
Q

What is Webpack?

A

webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser,

129
Q

How do you add a devDependency to a package?

A

install them in the root directory of your package using the –save-dev flag for dependencies

130
Q

What is an NPM script?

A

An npm script is a convenient way to bundle common shell commands for your project.

131
Q

How do you execute Webpack with npm run?

A

npm run build

132
Q

How are ES Modules different from CommonJS modules?

A

CommonJs Modules are the dominant implementation of standard in node js, require is standard in requireJs

133
Q

What kind of modules can Webpack support?

A

CommonJS Modules

134
Q

What is React?

A

React is a JavaScript library for creating user interfaces.

135
Q

What is a React element?

A

An element created with react

136
Q

How do you mount a React element to the DOM?

A

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

137
Q

What is Babel?

A

A way to reconfigure your code to be reverse compatible

138
Q

How can you make Babel and Webpack work together?

A

Babel loader

139
Q

What is JSX?

A

JSX is a syntax extension to JavaScript

140
Q

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

A

Since JSX compiles into calls to React.createElement, the React library must also always be in scope from your JSX code.

141
Q

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

A

babel-loader

142
Q

What is a React component?

A

A react component is a is a JavaScript function that returns a React element

143
Q

How do you define a function component in React?

A

function (props) { return }

144
Q

How do you mount a component to the DOM?

A

ReactDOM.render ( element, document.getElementById)

145
Q

What are props in React?

A

Properties

146
Q

How do you pass props to a component?

A

You pass props to a component by calling the function using JSX syntax in the render method

147
Q

How do you write JavaScript expressions in JSX?

A

{}

148
Q

How do you create “class” component in React?

A

Extend React Component

149
Q

How do you access props in a class component?

A

with this

150
Q

What is the purpose of state in React?

A

“state” is what allows you to create components that are dynamic and interactive.

151
Q

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

A

map

152
Q

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

A

the ID of the element

153
Q

What are controlled components?

A

Its the input value of the submit and the onChange

154
Q

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

A

onChange and the value

155
Q

What does express.static() return?

A

a middlewear function

156
Q

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

A

a string of the current working directory path

157
Q

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

A

join() method joins all given path segments together using the platform-specific separator as a delimiter, then normalizes the resulting path.

158
Q

What does fetch() return?

A

Returns the http response

159
Q

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

A

Get

160
Q

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

A

Pass it as a second argument

161
Q

When does React call a component’s componentDidMount method?

A

after the component gets mounted on the DOM.

162
Q

Name three React.Component lifecycle methods.

A

compenentdidmount, componentdidupdate, componentwillunmount

163
Q

How do you pass data to a child component?

A

Create a callback function in the parent component
Pass the callback function in the parent as a prop to the child component.
The child component calls the parent callback function using props.

164
Q

myFunction()();

A

it must be a function

165
Q

const wrap = value => () => value;

A

it returns 2 functions and stores them into a variable

166
Q

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

A

when it is defined

167
Q

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

A

closure