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
What number represents the first index of an array?
0
26
What is the length property of an array?
Calculates the total length of an array
27
How do you calculate the last index of an array?
-1
28
Why do we log things to the console?
console.log
29
What is a method?
a method is a function which is a property of an object
30
How is a method different from any other function?
it is a object reference to a function
31
How do you remove the last element from an array?
.pop() method
32
How do you round a number down to the nearest integer?
.floor() method
33
How do you generate a random number?
.random() method
34
How do you delete an element from an array?
.splice() method
35
How do you append an element to an array?
.push() method
36
How do you break a string up into an array?
.split() method
37
Do string methods change the original string? How would you check if you weren't sure?
No they dont
38
Is the return value of a function or method useful in every situation?
No
39
Roughly how many array methods are there according to the MDN Web docs?
a lot.
40
What three-letter acronym should you always include in your Google search about a JavaScript method or CSS property?
MDN
41
Give 6 examples of comparison operators.
==, !=, ===, !==, >, =, <= | equal, not equal to, strictly equal, strictly inequal, greater than
42
What data type do comparison expressions evaluate to?
boolean: true, false
43
What is the purpose of an if statement?
it allows your code to execute the statement between the brackets or to go on to the else
44
Is else required in order to use an if statement?
no
45
Describe the syntax (structure) of an if statement.
if (condition) {statement} else
46
What are the three logical operators?
&&, ||, and ~
47
How do you compare two different expressions in the same condition?
==
48
What is the purpose of a loop?
To loop throat a a condition until something is executed
49
What is the purpose of a condition expression in a loop?
to evaluate if something is true or false
50
What does "iteration" mean in the context of loops?
the amount of times it repeats
51
When does the condition expression of a while loop get evaluated?
before the loop
52
When does the initialization expression of a for loop get evaluated?
at the beginning of the loop
53
When does the condition expression of a for loop get evaluated?
after the initialization
54
When does the final expression of a for loop get evaluated?
In the return statement
55
Why do we log things to the console?
to let us know what we are doing
56
What is a method?
A method is a function which is a property of an object.
57
How can you tell the difference between a method definition and a method call?
method definition is going to have everything and a method call is the name of the object.method()
58
What is a code block? What are some examples of a code block?
``` 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; } ```
59
What does block scope mean?
Not attached to global scope
60
What is the scope of a variable declared with const or let?
Block Scoped
61
What is the difference between let and const?
Let is not initialized to any value, Const creates a read-only reference to a value
62
Why is it possible to .push() a new value into a const variable that points to an Array?
It allows you to change the arrays elements, however you cannot reassign the array to another array
63
How should you decide on which type of declaration to use?
use let if the variable's value will change during the code
64
What is the syntax for writing a template literal?
use the backtick ( ` ) character
65
What is "string interpolation"?
the process of embedding an expression into part of a string.
66
What is destructuring, conceptually?
extracting data from arrays or objects
67
What is the syntax for Object destructuring?
const { identifier } = expression
68
What is the syntax for Array destructuring?
const [ identifier ] = expression
69
How can you tell the difference between destructuring and creating Object/Array literals?
one uses square brackets and the other uses curly braces.
70
What is the syntax for defining an arrow function?
variable = () => { }
71
When an arrow function's body is left without curly braces, what changes in its functionality?
It has an implicit return
72
How is the value of this determined within an arrow function?
an arrow function captures the this value of the enclosing context instead of creating its own this context
73
What is a CLI?
A command line interface
74
What is a GUI?
Graphical user interface
75
``` 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 ```
``` 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
What are the three virtues of a great programmer?
laziness, impatience, hubris
77
What is Node.js?
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
What can Node.js be used for?
web sites and back-end API services
79
What is a REPL?
Read–eval–print loop
80
When was Node.js created?
2009
81
What back end languages have you heard of?
node.js, java, ruby, python, php, c, c++, c#, php, javascript, sql*, go, rust, swift, assembly,
82
What is a computer process?
Its a program running on your computer
83
Roughly how many computer processes are running on your host operating system (Task Manager or Activity Monitor)?
about 300
84
Why should a full stack Web developer know that computer processes exist?
To know what processes are running.
85
What is the process object in a Node.js program?
The process object is a global that provides information about, and control over, the current Node.js process
86
How do you access the process object in a Node.js program?
process
87
What is the data type of process.argv in Node.js?
an array of strings
88
What is a JavaScript module?
a "module" is a single .js file.
89
What values are passed into a Node.js module's local scope?
__dirname, __filename, module, exports, required
90
Give two examples of truly global variables in a Node.js program.
process and console
91
What is a directory?
a folder
92
What is an absolute file path?
An absolute path always contains the root element and the complete directory list required to locate the file.
93
What module does Node.js include for manipulating the file system?
fs module
94
What method is available in the Node.js fs module for writing data to a file?
fs writefile
95
What is a client?
someone who intiates communication sessions with servers, service requesters
96
What is a server?
providers of a resource or service
97
Which HTTP method does a browser issue to a web server when you visit a URL?
HTTP GET request
98
What is on the first line of an HTTP request message?
The start line, which describes the request being implemented
99
What is on the first line of an HTTP response message?
A header line with the status code, http version,
100
What are HTTP headers?
Meta data, Shows information about the request and the response
101
Is a body required for a valid HTTP message?
No, the body is optional
102
What is NPM?
npm is a software registry meaning people can share and borrow packages and can use npm to manage private development as well
103
What is a package?
A package is a file or directory that is described by a package.json file.
104
How can you create a package.json with npm?
npm init --yes
105
What is a dependency and how to you add one to a package?
the install command and its
106
What happens when you add a dependency to a package with npm?
It adds a node-modules directory
107
How do you add express to your package dependencies?
install it with npm
108
What Express application method starts the server and binds it to a network PORT?
listen method
109
How do you mount a middleware with an Express application?
call a middleware method, use()
110
Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?
the req and res objects
111
What is the appropriate Content-Type header for HTTP messages that contain JSON in their bodies?
application/json
112
What is PostgreSQL and what are some alternative relational databases?
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
What are some advantages of learning a relational database?
they support good guarantees about data integrity.
114
What is one way to see if PostgreSQL is running?
sudo service postgresql status
115
What is a database schema?
A schema defines how the data in a relational database should be organized.
116
What is a table?
You might visualize a database table as a sort of spreadsheet where each row is a record in that spreadsheet
117
What is a row?
A table is a list of rows each having the same set of attributes.
118
What are the three states a Promise can be in?
pending, fulfilled, rejected
119
How do you handle the fulfillment of a Promise?
use the then method to return a promise
120
How do you handle the rejection of a Promise?
use the catch method to return a promise with rejected cases only
121
What is Array.prototype.filter useful for?
For creating a new array with all elements that pass the test implemented b y the provided function
122
What is Array.prototype.map useful for?
Creating a new array populated with the results of a calling a provided function on every element in the calling array.
123
What is Array.prototype.reduce useful for?
Return the sum of all elements in array by executing a user supplied reducer callback function
124
What is "syntactic sugar"?
A syntax within a programming language that is designed to make things easier to read or to express.
125
What is the typeof an ES6 class?
function
126
Describe ES6 class syntax.
Class keyword, constructor
127
What is "refactoring"?
Restructuring existing code without changing its behavior
128
What is Webpack?
webpack is a module bundler. Its main purpose is to bundle JavaScript files for usage in a browser,
129
How do you add a devDependency to a package?
install them in the root directory of your package using the --save-dev flag for dependencies
130
What is an NPM script?
An npm script is a convenient way to bundle common shell commands for your project.
131
How do you execute Webpack with npm run?
npm run build
132
How are ES Modules different from CommonJS modules?
CommonJs Modules are the dominant implementation of standard in node js, require is standard in requireJs
133
What kind of modules can Webpack support?
CommonJS Modules
134
What is React?
React is a JavaScript library for creating user interfaces.
135
What is a React element?
An element created with react
136
How do you mount a React element to the DOM?
ReactDOM.render(element, container[, callback])
137
What is Babel?
A way to reconfigure your code to be reverse compatible
138
How can you make Babel and Webpack work together?
Babel loader
139
What is JSX?
JSX is a syntax extension to JavaScript
140
Why must the React object be imported when authoring JSX in a module?
Since JSX compiles into calls to React.createElement, the React library must also always be in scope from your JSX code.
141
How can you make Webpack and Babel work together to convert JSX into valid JavaScript?
babel-loader
142
What is a React component?
A react component is a is a JavaScript function that returns a React element
143
How do you define a function component in React?
function (props) { return }
144
How do you mount a component to the DOM?
ReactDOM.render ( element, document.getElementById)
145
What are props in React?
Properties
146
How do you pass props to a component?
You pass props to a component by calling the function using JSX syntax in the render method
147
How do you write JavaScript expressions in JSX?
{}
148
How do you create "class" component in React?
Extend React Component
149
How do you access props in a class component?
with this
150
What is the purpose of state in React?
“state” is what allows you to create components that are dynamic and interactive.
151
What Array method is commonly used to create a list of React elements?
map
152
What is the best value to use as a "key" prop when rendering lists?
the ID of the element
153
What are controlled components?
Its the input value of the submit and the onChange
154
What two props must you pass to an input for it to be "controlled"?
onChange and the value
155
What does express.static() return?
a middlewear function
156
What is the local __dirname variable in a Node.js module?
a string of the current working directory path
157
What does the join() method of Node's path module do?
join() method joins all given path segments together using the platform-specific separator as a delimiter, then normalizes the resulting path.
158
What does fetch() return?
Returns the http response
159
What is the default request method used by fetch()?
Get
160
How do you specify the request method (GET, POST, etc.) when calling fetch?
Pass it as a second argument
161
When does React call a component's componentDidMount method?
after the component gets mounted on the DOM.
162
Name three React.Component lifecycle methods.
compenentdidmount, componentdidupdate, componentwillunmount
163
How do you pass data to a child component?
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
myFunction()();
it must be a function
165
const wrap = value => () => value;
it returns 2 functions and stores them into a variable
166
In JavaScript, when is a function's scope determined; when it is called or when it is defined?
when it is defined
167
What allows JavaScript functions to "remember" values from their surroundings?
closure