Module 3 Flashcards

1
Q

What is Array.prototype.filter useful for?

A

for finding values in an array

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

What is Array.prototype.map useful for?

A

for applying a function to every value of an array

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

What is Array.prototype.reduce useful for?

A

applying a function to and compile all values in an array into a single value

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

What is “syntactic sugar”?

A

a way to increase code readability, but does not increase functionality

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

What is the typeof an ES6 class?

A

function

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

Describe ES6 class syntax.

A
class \_\_className\_\_ {
    constructor (\_\_para1\_\_, \_\_para2\_\_) {
 this.\_\_prop1\_\_ = \_\_\_\_;
this.\_\_prop2\_\_ = \_\_\_\_;
}
\_\_method1\_\_() {}
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is “refactoring”?

A

refactoring is the reorganization of code to increase efficiency without changing the functionality

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

What is Webpack?

A

a program that compiles JS files and uses immediately invoked function expressions (IIFE) to run the JS modules

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

How do you add a devDependency to a package?

A

npm install –save-dev

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

What is an NPM script?

A

a package of pre-written code that you can import and use in your code

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

How do you execute Webpack with npm run?

A

use npm install –save-dev webpack

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

How are ES Modules different from CommonJS modules?

A

they use ‘import’ and ‘export’ statements to reference other modules vs ‘require’ and ‘module.exports’ statements; standardized module import/export syntax for use with bundlers

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

What kind of modules can Webpack support?

A

ECMAScript, CommonJS, AMD

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

What is React?

A

a framework that allows components to update w/out reloading the page

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

What is a React element?

A

an object that describes a component instance or DOM node and its desired properties; not an HTML element, just contains info about a component

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

How do you mount a React element to the DOM?

A

ReactDOM.render()

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

What is Babel?

A

a toolkit that converts source code into a backward compatible version

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

What is a Plug-in?

A

a downloadable add-in that adds a feature to an existing piece of software

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

What is a Webpack loader?

A

an add-in that pre-processes code as modules are compiled

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

How can you make Babel and Webpack work together?

A

using the babel-loader

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

What is JSX?

A

an html-like syntax that gets converted to react elements

22
Q

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

A

because JSX compiles calls into React.createElement()

23
Q

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

A

using the Babel plugin transform-react-jsx

24
Q

What is a React component?

A

JS functions that return React elements

25
How do you define a function component in React?
like a normal JS function; use capital letter for funct name
26
How do you mount a component to the DOM?
ReactDOM.render(element, htmlComponent)
27
What are props in React?
obj that passes info to React components; a way to get outside info into component; key:value pair in JSX gets added to props
28
How do you pass props to a component?
add it as an attribute (key:value pair) to the component call
29
How do you write JavaScript expressions in JSX?
within {}
30
How do you create "class" component in React?
``` by using "class __className__ extends React.Component{ render() {} }" ```
31
How do you access props in a class component?
this.props
32
What is the purpose of state in React?
allows us to control what is displayed by updating based on changes to state
33
How to you pass an event handler to a React element?
as an attribute; < __JSX elm__ __eventHandler__ = __callback__ >
34
What are controlled components?
whose value and route of submittal is controlled by this.state
35
What two props must you pass to an input for it to be "controlled"?
value={this.state.__value__} and onChange event handler
36
What Array method is commonly used to create a list of React elements?
--
37
What is the best value to use as a "key" prop when rendering lists?
--
38
What does express.static() return?
function
39
What is the local __dirname variable in a Node.js module?
the directory that the node module is running in; folder that the file __dirname is in
40
What does the join() method of Node's path module do?
concatenates path names
41
What does fetch() return?
a Promise
42
What is the default request method used by fetch()?
GET
43
How do you specify the request method (GET, POST, etc.) when calling fetch?
in the init obj; using 'method' prop
44
When does React call a component's componentDidMount method?
runs after the component mounts on the DOM; ONLY called after the first render
45
Name three React.Component lifecycle methods.
componentDidMount, componentWillUnMount, componentDidUpdate
46
How do you pass data to a child component?
props
47
What must the return value of myFunction be if the following expression is possible? myFunction()()
-
48
``` What does this code do? const wrap = value => () => value; ```
-
49
In JavaScript, when is a function's scope determined; when it is called or when it is defined?
-
50
What allows JavaScript functions to "remember" values from their surroundings?
--